Work on layered tile maps.

This commit is contained in:
Relintai 2024-03-03 12:59:36 +01:00
parent 2783a9d58a
commit 0f07cedf57
12 changed files with 337 additions and 317 deletions

View File

@ -31,10 +31,13 @@
#include "atlas_merging_dialog.h"
#include "editor/editor_properties_vector.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/themes/editor_scale.h"
#include "core/object/undo_redo.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_properties.h"
#include "editor/editor_scale.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
#include "scene/gui/split_container.h"
#include "scene/main/control.h"
#include "scene/resources/texture.h"
@ -48,7 +51,9 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<LayeredTileSetAtlasSo
merged_mapping.clear();
if (p_atlas_sources.size() >= 2) {
Ref<Image> output_image = Image::create_empty(1, 1, false, Image::FORMAT_RGBA8);
Ref<Image> output_image;
output_image.instance();
output_image->create(1, 1, false, Image::FORMAT_RGBA8);
// Compute the new texture region size.
Vector2i new_texture_region_size;
@ -62,7 +67,7 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<LayeredTileSetAtlasSo
int line_height = 0;
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
const Ref<LayeredTileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
Ref<Image> input_image = atlas_source->get_texture()->get_image();
Ref<Image> input_image = atlas_source->get_texture()->get_data();
if (input_image->get_format() != Image::FORMAT_RGBA8) {
input_image->convert(Image::FORMAT_RGBA8);
}
@ -107,37 +112,46 @@ void AtlasMergingDialog::_generate_merged(const Vector<Ref<LayeredTileSetAtlasSo
}
merged->set_name(p_atlas_sources[0]->get_name());
merged->set_texture(ImageTexture::create_from_image(output_image));
Ref<ImageTexture> oit;
oit.instance();
oit->create_from_image(output_image);
merged->set_texture(oit);
merged->set_texture_region_size(new_texture_region_size);
// Copy the tiles to the merged LayeredTileSetAtlasSource.
for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) {
const Ref<LayeredTileSetAtlasSource> &atlas_source = p_atlas_sources[source_index];
for (KeyValue<Vector2i, Vector2i> tile_mapping : merged_mapping[source_index]) {
for (HashMap<Vector2i, Vector2i>::Element *tile_mapping = merged_mapping[source_index].front(); tile_mapping; tile_mapping = tile_mapping->next) {
// Create tiles and alternatives, then copy their properties.
for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_mapping.key); alternative_index++) {
int alternative_id = atlas_source->get_alternative_tile_id(tile_mapping.key, alternative_index);
for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_mapping->key()); alternative_index++) {
int alternative_id = atlas_source->get_alternative_tile_id(tile_mapping->key(), alternative_index);
int changed_id = -1;
if (alternative_id == 0) {
merged->create_tile(tile_mapping.value, atlas_source->get_tile_size_in_atlas(tile_mapping.key));
int count = atlas_source->get_tile_animation_frames_count(tile_mapping.key);
merged->set_tile_animation_frames_count(tile_mapping.value, count);
merged->create_tile(tile_mapping->value(), atlas_source->get_tile_size_in_atlas(tile_mapping->key()));
int count = atlas_source->get_tile_animation_frames_count(tile_mapping->key());
merged->set_tile_animation_frames_count(tile_mapping->value(), count);
for (int i = 0; i < count; i++) {
merged->set_tile_animation_frame_duration(tile_mapping.value, i, atlas_source->get_tile_animation_frame_duration(tile_mapping.key, i));
merged->set_tile_animation_frame_duration(tile_mapping->value(), i, atlas_source->get_tile_animation_frame_duration(tile_mapping->key(), i));
}
merged->set_tile_animation_speed(tile_mapping.value, atlas_source->get_tile_animation_speed(tile_mapping.key));
merged->set_tile_animation_mode(tile_mapping.value, atlas_source->get_tile_animation_mode(tile_mapping.key));
merged->set_tile_animation_speed(tile_mapping->value(), atlas_source->get_tile_animation_speed(tile_mapping->key()));
merged->set_tile_animation_mode(tile_mapping->value(), atlas_source->get_tile_animation_mode(tile_mapping->key()));
} else {
changed_id = merged->create_alternative_tile(tile_mapping.value, alternative_index);
changed_id = merged->create_alternative_tile(tile_mapping->value(), alternative_index);
}
// Copy the properties.
TileData *src_tile_data = atlas_source->get_tile_data(tile_mapping.key, alternative_id);
LayeredTileData *src_tile_data = atlas_source->get_tile_data(tile_mapping->key(), alternative_id);
List<PropertyInfo> properties;
src_tile_data->get_property_list(&properties);
TileData *dst_tile_data = merged->get_tile_data(tile_mapping.value, changed_id == -1 ? alternative_id : changed_id);
for (PropertyInfo property : properties) {
LayeredTileData *dst_tile_data = merged->get_tile_data(tile_mapping->value(), changed_id == -1 ? alternative_id : changed_id);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
PropertyInfo &property = E->get();
if (!(property.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@ -166,14 +180,14 @@ void AtlasMergingDialog::_update_texture() {
preview->set_texture(merged->get_texture());
preview->show();
select_2_atlases_label->hide();
get_ok_button()->set_disabled(false);
get_ok()->set_disabled(false);
merge_button->set_disabled(false);
} else {
_generate_merged(Vector<Ref<LayeredTileSetAtlasSource>>(), next_line_after_column);
preview->set_texture(Ref<Texture>());
preview->hide();
select_2_atlases_label->show();
get_ok_button()->set_disabled(true);
get_ok()->set_disabled(true);
merge_button->set_disabled(true);
}
}
@ -182,14 +196,15 @@ void AtlasMergingDialog::_merge_confirmed(const String &p_path) {
ERR_FAIL_COND(!merged.is_valid());
Ref<ImageTexture> output_image_texture = merged->get_texture();
output_image_texture->get_image()->save_png(p_path);
output_image_texture->get_data()->save_png(p_path);
ResourceLoader::import(p_path);
Ref<Texture> new_texture_resource = ResourceLoader::load(p_path, "Texture2D");
merged->set_texture(new_texture_resource);
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Merge LayeredTileSetAtlasSource"));
int next_id = tile_set->get_next_source_id();
undo_redo->add_do_method(*tile_set, "add_source", merged, next_id);
@ -223,13 +238,17 @@ void AtlasMergingDialog::_merge_confirmed(const String &p_path) {
hide();
}
void AtlasMergingDialog::_atlases_list_multi_selected(int p_index, bool p_selected) {
_update_texture();
}
void AtlasMergingDialog::ok_pressed() {
delete_original_atlases = false;
editor_file_dialog->popup_file_dialog();
editor_file_dialog->popup_centered_ratio();
}
void AtlasMergingDialog::cancel_pressed() {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
for (int i = 0; i < commited_actions_count; i++) {
undo_redo->undo();
}
@ -239,7 +258,7 @@ void AtlasMergingDialog::cancel_pressed() {
void AtlasMergingDialog::custom_action(const String &p_action) {
if (p_action == "merge") {
delete_original_atlases = true;
editor_file_dialog->popup_file_dialog();
editor_file_dialog->popup_centered_ratio();
}
}
@ -270,6 +289,13 @@ void AtlasMergingDialog::_notification(int p_what) {
}
}
void AtlasMergingDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_property_changed"), &AtlasMergingDialog::_property_changed);
ClassDB::bind_method(D_METHOD("_update_texture"), &AtlasMergingDialog::_update_texture);
ClassDB::bind_method(D_METHOD("_merge_confirmed"), &AtlasMergingDialog::_merge_confirmed);
ClassDB::bind_method(D_METHOD("_atlases_list_multi_selected"), &AtlasMergingDialog::_atlases_list_multi_selected);
}
void AtlasMergingDialog::update_tile_set(Ref<LayeredTileSet> p_tile_set) {
ERR_FAIL_COND(!p_tile_set.is_valid());
tile_set = p_tile_set;
@ -288,7 +314,7 @@ void AtlasMergingDialog::update_tile_set(Ref<LayeredTileSet> p_tile_set) {
}
}
get_ok_button()->set_disabled(true);
get_ok()->set_disabled(true);
merge_button->set_disabled(true);
commited_actions_count = 0;
@ -300,8 +326,8 @@ AtlasMergingDialog::AtlasMergingDialog() {
set_hide_on_ok(false);
// Ok buttons
set_ok_button_text(TTR("Merge (Keep original Atlases)"));
get_ok_button()->set_disabled(true);
get_ok()->set_text(TTR("Merge (Keep original Atlases)"));
get_ok()->set_disabled(true);
merge_button = add_button(TTR("Merge"), true, "merge");
merge_button->set_disabled(true);
@ -312,19 +338,16 @@ AtlasMergingDialog::AtlasMergingDialog() {
// Atlas sources item list.
atlas_merging_atlases_list = memnew(ItemList);
atlas_merging_atlases_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
atlas_merging_atlases_list->set_fixed_icon_size(Size2(60, 60) * EDSCALE);
atlas_merging_atlases_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
atlas_merging_atlases_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
atlas_merging_atlases_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
atlas_merging_atlases_list->set_custom_minimum_size(Size2(100, 200));
atlas_merging_atlases_list->set_select_mode(ItemList::SELECT_MULTI);
atlas_merging_atlases_list->connect("multi_selected", callable_mp(this, &AtlasMergingDialog::_update_texture).unbind(2));
atlas_merging_atlases_list->connect("multi_selected", this, "_atlases_list_multi_selected");
atlas_merging_h_split_container->add_child(atlas_merging_atlases_list);
VBoxContainer *atlas_merging_right_panel = memnew(VBoxContainer);
atlas_merging_right_panel->set_h_size_flags(Control::SIZE_EXPAND_FILL);
atlas_merging_right_panel->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
atlas_merging_h_split_container->add_child(atlas_merging_right_panel);
// Settings.
@ -336,7 +359,7 @@ AtlasMergingDialog::AtlasMergingDialog() {
columns_editor_property->set_label(TTR("Next Line After Column"));
columns_editor_property->set_object_and_property(this, "next_line_after_column");
columns_editor_property->update_property();
columns_editor_property->connect("property_changed", callable_mp(this, &AtlasMergingDialog::_property_changed));
columns_editor_property->connect("property_changed", this, "_property_changed");
atlas_merging_right_panel->add_child(columns_editor_property);
// Preview.
@ -347,7 +370,7 @@ AtlasMergingDialog::AtlasMergingDialog() {
preview = memnew(TextureRect);
preview->set_h_size_flags(Control::SIZE_EXPAND_FILL);
preview->set_v_size_flags(Control::SIZE_EXPAND_FILL);
preview->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
//preview->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
preview->hide();
preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
atlas_merging_right_panel->add_child(preview);
@ -355,15 +378,15 @@ AtlasMergingDialog::AtlasMergingDialog() {
select_2_atlases_label = memnew(Label);
select_2_atlases_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
select_2_atlases_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
select_2_atlases_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
select_2_atlases_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
select_2_atlases_label->set_align(Label::ALIGN_CENTER);
select_2_atlases_label->set_valign(Label::VALIGN_CENTER);
select_2_atlases_label->set_text(TTR("Please select two atlases or more."));
atlas_merging_right_panel->add_child(select_2_atlases_label);
// The file dialog to choose the texture path.
editor_file_dialog = memnew(EditorFileDialog);
editor_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
editor_file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
editor_file_dialog->add_filter("*.png");
editor_file_dialog->connect("file_selected", callable_mp(this, &AtlasMergingDialog::_merge_confirmed));
editor_file_dialog->connect("file_selected", this, "_merge_confirmed");
add_child(editor_file_dialog);
}

View File

@ -68,6 +68,7 @@ private:
void _generate_merged(const Vector<Ref<LayeredTileSetAtlasSource>> &p_atlas_sources, int p_max_columns);
void _update_texture();
void _merge_confirmed(const String &p_path);
void _atlases_list_multi_selected(int p_index, bool p_selected);
protected:
virtual void ok_pressed();
@ -78,6 +79,7 @@ protected:
bool _get(const StringName &p_name, Variant &r_ret) const;
void _notification(int p_what);
static void _bind_methods();
public:
void update_tile_set(Ref<LayeredTileSet> p_tile_set);

View File

@ -29,13 +29,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tile_atlas_view.h"
#include "layered_tile_atlas_view.h"
#include "../layered_tile_map.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/themes/editor_scale.h"
#include "scene/2d/tile_map.h"
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
@ -50,13 +50,13 @@ void LayeredTileAtlasView::gui_input(const Ref<InputEvent> &p_event) {
void LayeredTileAtlasView::_pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event) {
panning += p_scroll_vec;
_update_zoom_and_panning(true);
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
void LayeredTileAtlasView::_zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event) {
zoom_widget->set_zoom(zoom_widget->get_zoom() * p_zoom_factor);
_update_zoom_and_panning(true);
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
Size2i LayeredTileAtlasView::_compute_base_tiles_control_size() {
@ -133,7 +133,8 @@ void LayeredTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
// Center of panel.
panning = panning * zoom / previous_zoom;
}
button_center_view->set_disabled(panning.is_zero_approx());
button_center_view->set_disabled(panning.is_equal_approx(Vector2()));
previous_zoom = zoom;
@ -141,20 +142,20 @@ void LayeredTileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) {
center_container->set_size(center_container->get_minimum_size());
}
void LayeredTileAtlasView::_zoom_widget_changed() {
void LayeredTileAtlasView::_zoom_widget_changed(float val) {
_update_zoom_and_panning();
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
void LayeredTileAtlasView::_center_view() {
panning = Vector2();
button_center_view->set_disabled(true);
_update_zoom_and_panning();
emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning);
emit_signal("transform_changed", zoom_widget->get_zoom(), panning);
}
void LayeredTileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
base_tiles_root_control->set_tooltip_text("");
base_tiles_root_control->set_tooltip("");
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
@ -163,7 +164,7 @@ void LayeredTileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEve
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
coords = tile_set_atlas_source->get_tile_at_coords(coords);
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
base_tiles_root_control->set_tooltip_text(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: 0"), source_id, coords));
base_tiles_root_control->set_tooltip(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: 0"), source_id, coords));
}
}
}
@ -287,7 +288,7 @@ void LayeredTileAtlasView::_draw_base_tiles() {
}
}
RID LayeredTileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map) {
RID LayeredTileAtlasView::_get_canvas_item_to_draw(const LayeredTileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map) {
Ref<Material> mat = p_for_data->get_material();
if (mat.is_null()) {
return p_base_item->get_canvas_item();
@ -303,13 +304,13 @@ RID LayeredTileAtlasView::_get_canvas_item_to_draw(const TileData *p_for_data, c
}
void LayeredTileAtlasView::_clear_material_canvas_items() {
for (KeyValue<Ref<Material>, RID> kv : material_tiles_draw) {
RS::get_singleton()->free(kv.value);
for (HashMap<Ref<Material>, RID>::Element *kv = material_tiles_draw.front(); kv; kv = kv->next) {
RS::get_singleton()->free(kv->value());
}
material_tiles_draw.clear();
for (KeyValue<Ref<Material>, RID> kv : material_alternatives_draw) {
RS::get_singleton()->free(kv.value);
for (HashMap<Ref<Material>, RID>::Element *kv = material_alternatives_draw.front(); kv; kv = kv->next) {
RS::get_singleton()->free(kv->value());
}
material_alternatives_draw.clear();
}
@ -368,7 +369,7 @@ void LayeredTileAtlasView::_draw_base_tiles_shape_grid() {
}
void LayeredTileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) {
alternative_tiles_root_control->set_tooltip_text("");
alternative_tiles_root_control->set_tooltip("");
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
@ -377,7 +378,7 @@ void LayeredTileAtlasView::_alternative_tiles_root_control_gui_input(const Ref<I
Vector2i coords = Vector2i(coords3.x, coords3.y);
int alternative_id = coords3.z;
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS && alternative_id != LayeredTileSetSource::INVALID_TILE_ALTERNATIVE) {
alternative_tiles_root_control->set_tooltip_text(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: %d"), source_id, coords, alternative_id));
alternative_tiles_root_control->set_tooltip(vformat(TTR("Source: %d\nAtlas coordinates: %s\nAlternative: %d"), source_id, coords, alternative_id));
}
}
}
@ -395,7 +396,7 @@ void LayeredTileAtlasView::_draw_alternatives() {
int alternatives_count = tile_set_atlas_source->get_alternative_tiles_count(atlas_coords);
for (int j = 1; j < alternatives_count; j++) {
int alternative_id = tile_set_atlas_source->get_alternative_tile_id(atlas_coords, j);
TileData *tile_data = tile_set_atlas_source->get_tile_data(atlas_coords, alternative_id);
LayeredTileData *tile_data = tile_set_atlas_source->get_tile_data(atlas_coords, alternative_id);
bool transposed = tile_data->get_transpose();
// Different materials need to be drawn with different CanvasItems.
@ -462,12 +463,12 @@ void LayeredTileAtlasView::set_atlas_source(LayeredTileSet *p_tile_set, LayeredT
alternative_tiles_drawing_root->set_size(_compute_alternative_tiles_control_size());
// Update.
base_tiles_draw->queue_redraw();
base_tiles_texture_grid->queue_redraw();
base_tiles_shape_grid->queue_redraw();
alternatives_draw->queue_redraw();
background_left->queue_redraw();
background_right->queue_redraw();
base_tiles_draw->update();
base_tiles_texture_grid->update();
base_tiles_shape_grid->update();
alternatives_draw->update();
background_left->update();
background_right->update();
}
float LayeredTileAtlasView::get_zoom() const {
@ -520,7 +521,7 @@ void LayeredTileAtlasView::_update_alternative_tiles_rect_cache() {
int line_height = 0;
for (int j = 1; j < alternatives_count; j++) {
int alternative_id = tile_set_atlas_source->get_alternative_tile_id(tile_id, j);
TileData *tile_data = tile_set_atlas_source->get_tile_data(tile_id, alternative_id);
LayeredTileData *tile_data = tile_set_atlas_source->get_tile_data(tile_id, alternative_id);
bool transposed = tile_data->get_transpose();
current.size = transposed ? Vector2i(texture_region_size.y, texture_region_size.x) : texture_region_size;
@ -540,10 +541,10 @@ void LayeredTileAtlasView::_update_alternative_tiles_rect_cache() {
}
Vector3i LayeredTileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const {
for (const KeyValue<Vector2, HashMap<int, Rect2i>> &E_coords : alternative_tiles_rect_cache) {
for (const KeyValue<int, Rect2i> &E_alternative : E_coords.value) {
if (E_alternative.value.has_point(p_pos)) {
return Vector3i(E_coords.key.x, E_coords.key.y, E_alternative.key);
for (const HashMap<Vector2, HashMap<int, Rect2i>>::Element *E_coords = alternative_tiles_rect_cache.front(); E_coords; E_coords = E_coords->next) {
for (const HashMap<int, Rect2i>::Element *E_alternative = E_coords->value().front(); E_alternative; E_alternative = E_alternative->next) {
if (E_alternative->value().has_point(p_pos)) {
return Vector3i(E_coords->key().x, E_coords->key().y, E_alternative->key());
}
}
}
@ -558,79 +559,82 @@ Rect2i LayeredTileAtlasView::get_alternative_tile_rect(const Vector2i p_coords,
return alternative_tiles_rect_cache[p_coords][p_alternative_tile];
}
void LayeredTileAtlasView::queue_redraw() {
base_tiles_draw->queue_redraw();
base_tiles_texture_grid->queue_redraw();
base_tiles_shape_grid->queue_redraw();
alternatives_draw->queue_redraw();
background_left->queue_redraw();
background_right->queue_redraw();
}
void LayeredTileAtlasView::_update_theme_item_cache() {
Control::_update_theme_item_cache();
theme_cache.center_view_icon = get_editor_theme_icon(SNAME("CenterView"));
theme_cache.checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
void LayeredTileAtlasView::update() {
base_tiles_draw->update();
base_tiles_texture_grid->update();
base_tiles_shape_grid->update();
alternatives_draw->update();
background_left->update();
background_right->update();
}
void LayeredTileAtlasView::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (!EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) {
break;
}
[[fallthrough]];
}
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED:
case NOTIFICATION_ENTER_TREE: {
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
} break;
case NOTIFICATION_THEME_CHANGED: {
theme_cache.center_view_icon = get_theme_icon("CenterView", "EditorIcons");
theme_cache.checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
button_center_view->set_icon(theme_cache.center_view_icon);
} break;
}
}
void LayeredTileAtlasView::_bind_methods() {
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::REAL, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
ClassDB::bind_method(D_METHOD("_zoom_widget_changed"), &LayeredTileAtlasView::_zoom_widget_changed);
ClassDB::bind_method(D_METHOD("_center_view"), &LayeredTileAtlasView::_center_view);
ClassDB::bind_method(D_METHOD("_zoom_callback"), &LayeredTileAtlasView::_zoom_callback);
ClassDB::bind_method(D_METHOD("gui_input"), &LayeredTileAtlasView::gui_input);
ClassDB::bind_method(D_METHOD("_base_tiles_root_control_gui_input"), &LayeredTileAtlasView::_base_tiles_root_control_gui_input);
ClassDB::bind_method(D_METHOD("_draw_background_left"), &LayeredTileAtlasView::_draw_background_left);
ClassDB::bind_method(D_METHOD("_draw_base_tiles"), &LayeredTileAtlasView::_draw_base_tiles);
ClassDB::bind_method(D_METHOD("_draw_base_tiles_texture_grid"), &LayeredTileAtlasView::_draw_base_tiles_texture_grid);
ClassDB::bind_method(D_METHOD("_draw_base_tiles_shape_grid"), &LayeredTileAtlasView::_draw_base_tiles_shape_grid);
ClassDB::bind_method(D_METHOD("_alternative_tiles_root_control_gui_input"), &LayeredTileAtlasView::_alternative_tiles_root_control_gui_input);
ClassDB::bind_method(D_METHOD("_draw_background_right"), &LayeredTileAtlasView::_draw_background_right);
ClassDB::bind_method(D_METHOD("_draw_alternatives"), &LayeredTileAtlasView::_draw_alternatives);
}
LayeredTileAtlasView::LayeredTileAtlasView() {
set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
Panel *panel = memnew(Panel);
panel->set_clip_contents(true);
panel->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
panel->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
panel->set_anchors_and_margins_preset(Control::PRESET_WIDE);
panel->set_h_size_flags(SIZE_EXPAND_FILL);
panel->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(panel);
zoom_widget = memnew(EditorZoomWidget);
add_child(zoom_widget);
zoom_widget->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
zoom_widget->connect("zoom_changed", callable_mp(this, &LayeredTileAtlasView::_zoom_widget_changed).unbind(1));
zoom_widget->set_anchors_and_margins_preset(Control::PRESET_TOP_LEFT, Control::PRESET_MODE_MINSIZE, 2 * EDSCALE);
zoom_widget->connect("zoom_changed", this, "_zoom_widget_changed");
zoom_widget->set_shortcut_context(this);
button_center_view = memnew(Button);
button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
button_center_view->set_grow_direction_preset(Control::PRESET_TOP_RIGHT);
button_center_view->connect("pressed", callable_mp(this, &LayeredTileAtlasView::_center_view));
button_center_view->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
//button_center_view->set_grow_direction_preset(Control::PRESET_TOP_RIGHT);
button_center_view->connect("pressed", this, "_center_view");
button_center_view->set_flat(true);
button_center_view->set_disabled(true);
button_center_view->set_tooltip_text(TTR("Center View"));
button_center_view->set_tooltip(TTR("Center View"));
add_child(button_center_view);
panner.instance();
panner->set_callbacks(callable_mp(this, &LayeredTileAtlasView::_pan_callback), callable_mp(this, &LayeredTileAtlasView::_zoom_callback));
panner->connect("panned", this, "_pan_callback");
panner->connect("zoomed", this, "_zoom_callback");
panner->set_enable_rmb(true);
center_container = memnew(CenterContainer);
center_container->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
center_container->set_anchors_preset(Control::PRESET_CENTER);
center_container->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::gui_input));
center_container->connect("focus_exited", callable_mp(panner.ptr(), &ViewPanner::release_pan_key));
center_container->connect("gui_input", this, "gui_input");
center_container->connect("focus_exited", panner.ptr(), "release_pan_key");
center_container->set_focus_mode(FOCUS_CLICK);
panel->add_child(center_container);
@ -660,74 +664,70 @@ LayeredTileAtlasView::LayeredTileAtlasView() {
Label *base_tile_label = memnew(Label);
base_tile_label->set_mouse_filter(Control::MOUSE_FILTER_PASS);
base_tile_label->set_text(TTR("Base Tiles"));
base_tile_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
base_tile_label->set_align(Label::ALIGN_CENTER);
left_vbox->add_child(base_tile_label);
base_tiles_root_control = memnew(Control);
base_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
base_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
base_tiles_root_control->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::_base_tiles_root_control_gui_input));
base_tiles_root_control->connect("gui_input", this, "_base_tiles_root_control_gui_input");
left_vbox->add_child(base_tiles_root_control);
background_left = memnew(Control);
background_left->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_left->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT);
background_left->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
background_left->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_background_left));
background_left->set_anchors_and_margins_preset(Control::PRESET_TOP_LEFT);
background_left->connect("draw", this, "_draw_background_left");
base_tiles_root_control->add_child(background_left);
base_tiles_drawing_root = memnew(Control);
base_tiles_drawing_root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_drawing_root->set_texture_filter(TEXTURE_FILTER_NEAREST);
base_tiles_root_control->add_child(base_tiles_drawing_root);
base_tiles_draw = memnew(Control);
base_tiles_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_draw->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_draw->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles));
base_tiles_draw->set_anchors_and_margins_preset(Control::PRESET_WIDE);
base_tiles_draw->connect("draw", this, "_draw_base_tiles");
base_tiles_drawing_root->add_child(base_tiles_draw);
base_tiles_texture_grid = memnew(Control);
base_tiles_texture_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_texture_grid->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_texture_grid->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles_texture_grid));
base_tiles_texture_grid->set_anchors_and_margins_preset(Control::PRESET_WIDE);
base_tiles_texture_grid->connect("draw", this, "_draw_base_tiles_texture_grid");
base_tiles_drawing_root->add_child(base_tiles_texture_grid);
base_tiles_shape_grid = memnew(Control);
base_tiles_shape_grid->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
base_tiles_shape_grid->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_tiles_shape_grid->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_base_tiles_shape_grid));
base_tiles_shape_grid->set_anchors_and_margins_preset(Control::PRESET_WIDE);
base_tiles_shape_grid->connect("draw", this, "_draw_base_tiles_shape_grid");
base_tiles_drawing_root->add_child(base_tiles_shape_grid);
// Alternative tiles.
Label *alternative_tiles_label = memnew(Label);
alternative_tiles_label->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
alternative_tiles_label->set_text(TTR("Alternative Tiles"));
alternative_tiles_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
alternative_tiles_label->set_align(Label::ALIGN_CENTER);
right_vbox->add_child(alternative_tiles_label);
alternative_tiles_root_control = memnew(Control);
alternative_tiles_root_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
alternative_tiles_root_control->set_v_size_flags(Control::SIZE_EXPAND_FILL);
alternative_tiles_root_control->connect("gui_input", callable_mp(this, &LayeredTileAtlasView::_alternative_tiles_root_control_gui_input));
alternative_tiles_root_control->connect("gui_input", this, "_alternative_tiles_root_control_gui_input");
right_vbox->add_child(alternative_tiles_root_control);
background_right = memnew(Control);
background_right->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
background_right->set_anchors_and_offsets_preset(Control::PRESET_TOP_LEFT);
background_right->set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
background_right->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_background_right));
background_right->set_anchors_and_margins_preset(Control::PRESET_TOP_LEFT);
background_right->connect("draw", this, "_draw_background_right");
alternative_tiles_root_control->add_child(background_right);
alternative_tiles_drawing_root = memnew(Control);
alternative_tiles_drawing_root->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
alternative_tiles_drawing_root->set_texture_filter(TEXTURE_FILTER_NEAREST);
alternative_tiles_root_control->add_child(alternative_tiles_drawing_root);
alternatives_draw = memnew(Control);
alternatives_draw->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
alternatives_draw->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
alternatives_draw->connect("draw", callable_mp(this, &LayeredTileAtlasView::_draw_alternatives));
alternatives_draw->set_anchors_and_margins_preset(Control::PRESET_WIDE);
alternatives_draw->connect("draw", this, "_draw_alternatives");
alternative_tiles_drawing_root->add_child(alternatives_draw);
}

View File

@ -33,7 +33,8 @@
/*************************************************************************/
#include "../layered_tile_set.h"
#include "editor/gui/editor_zoom_widget.h"
#include "editor/editor_zoom_widget.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/center_container.h"
@ -61,7 +62,7 @@ private:
CenterContainer *center_container = nullptr;
Vector2 panning;
void _update_zoom_and_panning(bool p_zoom_on_mouse_pos = false);
void _zoom_widget_changed();
void _zoom_widget_changed(float val);
void _center_view();
virtual void gui_input(const Ref<InputEvent> &p_event);
@ -93,7 +94,7 @@ private:
HashMap<Ref<Material>, RID> material_tiles_draw;
HashMap<Ref<Material>, RID> material_alternatives_draw;
void _draw_base_tiles();
RID _get_canvas_item_to_draw(const TileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map);
RID _get_canvas_item_to_draw(const LayeredTileData *p_for_data, const CanvasItem *p_base_item, HashMap<Ref<Material>, RID> &p_material_map);
void _clear_material_canvas_items();
Control *base_tiles_texture_grid = nullptr;
@ -121,8 +122,6 @@ private:
} theme_cache;
protected:
virtual void _update_theme_item_cache();
void _notification(int p_what);
static void _bind_methods();
@ -147,7 +146,7 @@ public:
} else {
base_tiles_root_control->add_child(p_control);
}
p_control->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
p_control->set_anchors_and_margins_preset(Control::PRESET_WIDE);
p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
};
@ -161,12 +160,12 @@ public:
} else {
alternative_tiles_root_control->add_child(p_control);
}
p_control->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
p_control->set_anchors_and_margins_preset(Control::PRESET_WIDE);
p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS);
};
// Redraw everything.
void queue_redraw();
void update();
LayeredTileAtlasView();
~LayeredTileAtlasView();

View File

@ -265,12 +265,12 @@ void GenericTilePolygonEditor::_base_control_draw() {
void GenericTilePolygonEditor::_center_view() {
panning = Vector2();
base_control->queue_redraw();
base_control->update();
button_center_view->set_disabled(true);
}
void GenericTilePolygonEditor::_zoom_changed() {
base_control->queue_redraw();
base_control->update();
}
void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
@ -291,26 +291,26 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
polygon.write[i] = polygon[i] * tile_set->get_tile_size();
}
undo_redo->add_do_method(this, "add_polygon", polygon);
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
undo_redo->add_undo_method(this, "clear_polygons");
for (const PoolVector2Array &poly : polygons) {
undo_redo->add_undo_method(this, "add_polygon", poly);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "update");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
undo_redo->commit_action(true);
} break;
case CLEAR_TILE: {
undo_redo->create_action(TTR("Clear Polygons"));
undo_redo->add_do_method(this, "clear_polygons");
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
undo_redo->add_undo_method(this, "clear_polygons");
for (const PoolVector2Array &polygon : polygons) {
undo_redo->add_undo_method(this, "add_polygon", polygon);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "update");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
undo_redo->commit_action(true);
} break;
@ -358,12 +358,12 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
}
undo_redo->add_do_method(this, "set_polygon", i, new_polygon);
}
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_do_method(this, "emit_signal", "polygons_changed");
for (unsigned int i = 0; i < polygons.size(); i++) {
undo_redo->add_undo_method(this, "set_polygon", i, polygons[i]);
}
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "update");
undo_redo->add_undo_method(this, "emit_signal", "polygons_changed");
undo_redo->commit_action(true);
} break;
@ -545,9 +545,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
undo_redo->add_do_method(this, "clear_polygons");
}
undo_redo->add_do_method(this, "add_polygon", in_creation_polygon);
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_undo_method(this, "remove_polygon", added);
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "update");
undo_redo->commit_action(false);
emit_signal(SNAME("polygons_changed"));
} else {
@ -593,8 +593,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]);
undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon);
}
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_undo_method(base_control, "update");
undo_redo->commit_action(false);
emit_signal(SNAME("polygons_changed"));
}
@ -603,9 +603,9 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
if (drag_type == DRAG_TYPE_DRAG_POINT) {
undo_redo->create_action(TTR("Edit Polygons"));
undo_redo->add_do_method(this, "set_polygon", drag_polygon_index, polygons[drag_polygon_index]);
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon);
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "update");
undo_redo->commit_action(false);
emit_signal(SNAME("polygons_changed"));
} else if (drag_type == DRAG_TYPE_CREATE_POINT) {
@ -638,8 +638,8 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
undo_redo->add_do_method(this, "set_polygon", closest_polygon, polygons[closest_polygon]);
undo_redo->add_undo_method(this, "set_polygon", closest_polygon, old_polygon);
}
undo_redo->add_do_method(base_control, "queue_redraw");
undo_redo->add_undo_method(base_control, "queue_redraw");
undo_redo->add_do_method(base_control, "update");
undo_redo->add_undo_method(base_control, "update");
undo_redo->commit_action(false);
emit_signal(SNAME("polygons_changed"));
drag_type = DRAG_TYPE_NONE;
@ -664,7 +664,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
}
}
base_control->queue_redraw();
base_control->update();
if (!use_undo_redo) {
memdelete(undo_redo);
@ -675,7 +675,7 @@ void GenericTilePolygonEditor::_set_snap_option(int p_index) {
current_snap_option = p_index;
button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(p_index));
snap_subdivision->set_visible(p_index == SNAP_GRID);
base_control->queue_redraw();
base_control->update();
_store_snap_options();
}
@ -745,7 +745,7 @@ void GenericTilePolygonEditor::set_background(Ref<Texture> p_texture, Rect2 p_re
background_v_flip = p_flip_v;
background_transpose = p_transpose;
background_modulate = p_modulate;
base_control->queue_redraw();
base_control->update();
}
int GenericTilePolygonEditor::get_polygon_count() {
@ -758,13 +758,13 @@ int GenericTilePolygonEditor::add_polygon(const Vector<Point2> &p_polygon, int p
if (p_index < 0) {
polygons.push_back(p_polygon);
base_control->queue_redraw();
base_control->update();
button_edit->set_pressed(true);
return polygons.size() - 1;
} else {
polygons.insert(p_index, p_polygon);
button_edit->set_pressed(true);
base_control->queue_redraw();
base_control->update();
return p_index;
}
}
@ -776,12 +776,12 @@ void GenericTilePolygonEditor::remove_polygon(int p_index) {
if (polygons.size() == 0) {
button_create->set_pressed(true);
}
base_control->queue_redraw();
base_control->update();
}
void GenericTilePolygonEditor::clear_polygons() {
polygons.clear();
base_control->queue_redraw();
base_control->update();
}
void GenericTilePolygonEditor::set_polygon(int p_polygon_index, const Vector<Point2> &p_polygon) {
@ -789,7 +789,7 @@ void GenericTilePolygonEditor::set_polygon(int p_polygon_index, const Vector<Poi
ERR_FAIL_COND(p_polygon.size() < 3);
polygons[p_polygon_index] = p_polygon;
button_edit->set_pressed(true);
base_control->queue_redraw();
base_control->update();
}
Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) {
@ -799,7 +799,7 @@ Vector<Point2> GenericTilePolygonEditor::get_polygon(int p_polygon_index) {
void GenericTilePolygonEditor::set_polygons_color(Color p_color) {
polygon_color = p_color;
base_control->queue_redraw();
base_control->update();
}
void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon_mode) {
@ -855,7 +855,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
button_expand->set_theme_type_variation("FlatButton");
button_expand->set_toggle_mode(true);
button_expand->set_pressed(false);
button_expand->set_tooltip_text(TTR("Expand editor"));
button_expand->set_tooltip(TTR("Expand editor"));
button_expand->connect("toggled", callable_mp(this, &GenericTilePolygonEditor::_toggle_expand));
toolbar->add_child(button_expand);
@ -866,21 +866,21 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
button_create->set_toggle_mode(true);
button_create->set_button_group(tools_button_group);
button_create->set_pressed(true);
button_create->set_tooltip_text(TTR("Add polygon tool"));
button_create->set_tooltip(TTR("Add polygon tool"));
toolbar->add_child(button_create);
button_edit = memnew(Button);
button_edit->set_theme_type_variation("FlatButton");
button_edit->set_toggle_mode(true);
button_edit->set_button_group(tools_button_group);
button_edit->set_tooltip_text(TTR("Edit points tool"));
button_edit->set_tooltip(TTR("Edit points tool"));
toolbar->add_child(button_edit);
button_delete = memnew(Button);
button_delete->set_theme_type_variation("FlatButton");
button_delete->set_toggle_mode(true);
button_delete->set_button_group(tools_button_group);
button_delete->set_tooltip_text(TTR("Delete points tool"));
button_delete->set_tooltip(TTR("Delete points tool"));
toolbar->add_child(button_delete);
button_advanced_menu = memnew(MenuButton);
@ -904,7 +904,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
toolbar->add_child(button_pixel_snap);
button_pixel_snap->set_flat(false);
button_pixel_snap->set_theme_type_variation("FlatMenuButton");
button_pixel_snap->set_tooltip_text(TTR("Toggle Grid Snap"));
button_pixel_snap->set_tooltip(TTR("Toggle Grid Snap"));
button_pixel_snap->get_popup()->add_item(TTR("Disable Snap"), SNAP_NONE);
button_pixel_snap->get_popup()->add_item(TTR("Half-Pixel Snap"), SNAP_HALF_PIXEL);
button_pixel_snap->get_popup()->add_item(TTR("Grid Snap"), SNAP_GRID);
@ -923,19 +923,19 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
add_child(root);
panel = memnew(Panel);
panel->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
panel->set_anchors_and_margins_preset(Control::PRESET_WIDE);
panel->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
root->add_child(panel);
base_control = memnew(Control);
base_control->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST);
base_control->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
base_control->set_anchors_and_margins_preset(Control::PRESET_WIDE);
base_control->connect("draw", callable_mp(this, &GenericTilePolygonEditor::_base_control_draw));
base_control->connect("gui_input", callable_mp(this, &GenericTilePolygonEditor::_base_control_gui_input));
base_control->set_clip_contents(true);
base_control->set_focus_mode(Control::FOCUS_CLICK);
root->add_child(base_control);
snap_subdivision->connect("value_changed", callable_mp((CanvasItem *)base_control, &CanvasItem::queue_redraw).unbind(1));
snap_subdivision->connect("value_changed", callable_mp((CanvasItem *)base_control, &CanvasItem::update).unbind(1));
snap_subdivision->connect("value_changed", callable_mp(this, &GenericTilePolygonEditor::_store_snap_options).unbind(1));
editor_zoom_widget = memnew(EditorZoomWidget);
@ -946,7 +946,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
root->add_child(editor_zoom_widget);
button_center_view = memnew(Button);
button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
button_center_view->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5);
button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view));
button_center_view->set_theme_type_variation("FlatButton");
button_center_view->set_disabled(true);
@ -1247,8 +1247,8 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
}
Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 4), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, 3, Color(0, 0, 0));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 4), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, color);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 4), text, Label::ALIGN_CENTER, string_size.x, font_size, 3, Color(0, 0, 0));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 4), text, Label::ALIGN_CENTER, string_size.x, font_size, color);
}
}
@ -1284,7 +1284,7 @@ void TileDataDefaultEditor::setup_property_editor(Variant::Type p_type, const St
property_editor->set_label(p_label);
}
property_editor->connect("property_changed", callable_mp(this, &TileDataDefaultEditor::_property_value_changed).unbind(1));
property_editor->set_tooltip_text(p_property);
property_editor->set_tooltip(p_property);
property_editor->update_property();
add_child(property_editor);
}
@ -1351,8 +1351,8 @@ void TileDataTextureOriginEditor::draw_over_tile(CanvasItem *p_canvas_item, Tran
Vector2 texture_origin = tile_data->get_texture_origin();
String text = vformat("%s", texture_origin);
Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, color);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, color);
}
}
@ -1399,8 +1399,8 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D
String text = vformat("%s", tile_data->get_y_sort_origin());
Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, color);
p_canvas_item->draw_string_outline(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(-texture_origin) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, color);
}
}
@ -1524,7 +1524,7 @@ void TileDataCollisionEditor::_polygons_changed() {
one_way_property_editor->set_label(one_way_property);
one_way_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
one_way_property_editor->connect("selected", callable_mp(this, &TileDataCollisionEditor::_property_selected));
one_way_property_editor->set_tooltip_text(one_way_property_editor->get_edited_property());
one_way_property_editor->set_tooltip(one_way_property_editor->get_edited_property());
one_way_property_editor->update_property();
add_child(one_way_property_editor);
property_editors[one_way_property] = one_way_property_editor;
@ -1536,7 +1536,7 @@ void TileDataCollisionEditor::_polygons_changed() {
one_way_margin_property_editor->set_label(one_way_margin_property);
one_way_margin_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
one_way_margin_property_editor->connect("selected", callable_mp(this, &TileDataCollisionEditor::_property_selected));
one_way_margin_property_editor->set_tooltip_text(one_way_margin_property_editor->get_edited_property());
one_way_margin_property_editor->set_tooltip(one_way_margin_property_editor->get_edited_property());
one_way_margin_property_editor->update_property();
add_child(one_way_margin_property_editor);
property_editors[one_way_margin_property] = one_way_margin_property_editor;
@ -1702,7 +1702,7 @@ TileDataCollisionEditor::TileDataCollisionEditor() {
linear_velocity_editor->set_label("linear_velocity");
linear_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
linear_velocity_editor->connect("selected", callable_mp(this, &TileDataCollisionEditor::_property_selected));
linear_velocity_editor->set_tooltip_text(linear_velocity_editor->get_edited_property());
linear_velocity_editor->set_tooltip(linear_velocity_editor->get_edited_property());
linear_velocity_editor->update_property();
add_child(linear_velocity_editor);
property_editors["linear_velocity"] = linear_velocity_editor;
@ -1712,7 +1712,7 @@ TileDataCollisionEditor::TileDataCollisionEditor() {
angular_velocity_editor->set_label("angular_velocity");
angular_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
angular_velocity_editor->connect("selected", callable_mp(this, &TileDataCollisionEditor::_property_selected));
angular_velocity_editor->set_tooltip_text(angular_velocity_editor->get_edited_property());
angular_velocity_editor->set_tooltip(angular_velocity_editor->get_edited_property());
angular_velocity_editor->update_property();
add_child(angular_velocity_editor);
property_editors["angular_velocity"] = angular_velocity_editor;
@ -1914,8 +1914,8 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(LayeredTileAtlasView *p_til
text = "-";
}
Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
p_canvas_item->draw_string_outline(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, color);
p_canvas_item->draw_string_outline(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, color);
}
}
}
@ -2106,8 +2106,8 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(LayeredTileAtlasView
text = "-";
}
Vector2 string_size = font->get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size);
p_canvas_item->draw_string_outline(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, HORIZONTAL_ALIGNMENT_CENTER, string_size.x, font_size, color);
p_canvas_item->draw_string_outline(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, 1, Color(0, 0, 0, 1));
p_canvas_item->draw_string(font, p_transform.xform(position) + Vector2i(-string_size.x / 2, string_size.y / 2), text, Label::ALIGN_CENTER, string_size.x, font_size, color);
}
}
}
@ -2814,7 +2814,7 @@ TileDataTerrainsEditor::TileDataTerrainsEditor() {
terrain_set_property_editor->set_object_and_property(dummy_object, "terrain_set");
terrain_set_property_editor->set_label("Terrain Set");
terrain_set_property_editor->connect("property_changed", callable_mp(this, &TileDataTerrainsEditor::_property_value_changed).unbind(1));
terrain_set_property_editor->set_tooltip_text(terrain_set_property_editor->get_edited_property());
terrain_set_property_editor->set_tooltip(terrain_set_property_editor->get_edited_property());
add_child(terrain_set_property_editor);
terrain_property_editor = memnew(EditorPropertyEnum);

View File

@ -32,7 +32,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tile_atlas_view.h"
#include "layered_tile_atlas_view.h"
#include "../layered_tile_map.h"
#include "editor/editor_properties.h"
@ -54,7 +54,7 @@ private:
protected:
Ref<LayeredTileSet> tile_set;
TileData *_get_tile_data(LayeredTileMapCell p_cell);
LayeredTileData *_get_tile_data(LayeredTileMapCell p_cell);
virtual void _tile_set_changed(){};
static void _bind_methods();

View File

@ -135,11 +135,11 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_transform_buttons() {
void LayeredTileMapLayerEditorTilesPlugin::_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("");
button->set_tooltip("");
}
for (Button *button : p_disabled_buttons) {
button->set_disabled(true);
button->set_tooltip_text(p_why_disabled);
button->set_tooltip(p_why_disabled);
}
}
@ -393,7 +393,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_atlas_view() {
tile_atlas_view->set_atlas_source(*tile_set, atlas_source, source_id);
LayeredTilesEditorUtils::get_singleton()->synchronize_atlas_view(tile_atlas_view);
tile_atlas_control->queue_redraw();
tile_atlas_control->update();
}
void LayeredTileMapLayerEditorTilesPlugin::_update_scenes_collection_view() {
@ -1812,8 +1812,8 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_tileset_selection_from_select
}
}
_update_source_display();
tile_atlas_control->queue_redraw();
alternative_tiles_control->queue_redraw();
tile_atlas_control->update();
alternative_tiles_control->update();
_update_transform_buttons();
}
@ -1893,7 +1893,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_atlas_control_mouse_exited() {
hovered_tile.source_id = LayeredTileSet::INVALID_SOURCE;
hovered_tile.set_atlas_coords(LayeredTileSetSource::INVALID_ATLAS_COORDS);
hovered_tile.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
tile_atlas_control->queue_redraw();
tile_atlas_control->update();
}
void LayeredTileMapLayerEditorTilesPlugin::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
@ -1937,8 +1937,8 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_atlas_control_gui_input(const R
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
tile_atlas_control->queue_redraw();
alternative_tiles_control->queue_redraw();
tile_atlas_control->update();
alternative_tiles_control->update();
}
Ref<InputEventMouseButton> mb = p_event;
@ -1998,7 +1998,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_atlas_control_gui_input(const R
}
tile_set_dragging_selection = false;
}
tile_atlas_control->queue_redraw();
tile_atlas_control->update();
}
}
@ -2051,7 +2051,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_alternatives_control_mouse_exit
hovered_tile.source_id = LayeredTileSet::INVALID_SOURCE;
hovered_tile.set_atlas_coords(LayeredTileSetSource::INVALID_ATLAS_COORDS);
hovered_tile.alternative_tile = LayeredTileSetSource::INVALID_TILE_ALTERNATIVE;
alternative_tiles_control->queue_redraw();
alternative_tiles_control->update();
}
void LayeredTileMapLayerEditorTilesPlugin::_tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event) {
@ -2094,8 +2094,8 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_alternatives_control_gui_input(
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
tile_atlas_control->queue_redraw();
alternative_tiles_control->queue_redraw();
tile_atlas_control->update();
alternative_tiles_control->update();
}
Ref<InputEventMouseButton> mb = p_event;
@ -2115,8 +2115,8 @@ void LayeredTileMapLayerEditorTilesPlugin::_tile_alternatives_control_gui_input(
}
_update_selection_pattern_from_tileset_tiles_selection();
}
tile_atlas_control->queue_redraw();
alternative_tiles_control->queue_redraw();
tile_atlas_control->update();
alternative_tiles_control->update();
}
}
@ -2215,7 +2215,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
paint_tool_button->set_toggle_mode(true);
paint_tool_button->set_button_group(tool_buttons_group);
paint_tool_button->set_shortcut(ED_SHORTCUT("tiles_editor/paint_tool", TTR("Paint"), Key::D));
paint_tool_button->set_tooltip_text(TTR("Shift: Draw line.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Shift: Draw rectangle."));
paint_tool_button->set_tooltip(TTR("Shift: Draw line.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Shift: Draw rectangle."));
paint_tool_button->connect("pressed", callable_mp(this, &LayeredTileMapLayerEditorTilesPlugin::_update_toolbar));
tilemap_tiles_tools_buttons->add_child(paint_tool_button);
viewport_shortcut_buttons.push_back(paint_tool_button);
@ -2262,7 +2262,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
picker_button->set_toggle_mode(true);
picker_button->set_shortcut(ED_SHORTCUT("tiles_editor/picker", TTR("Picker"), Key::P));
Key key = (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios")) ? Key::META : Key::CTRL;
picker_button->set_tooltip_text(vformat(TTR("Alternatively hold %s with other tools to pick tile."), find_keycode_name(key)));
picker_button->set_tooltip(vformat(TTR("Alternatively hold %s with other tools to pick tile."), find_keycode_name(key)));
picker_button->connect("pressed", callable_mp(CanvasItemEditor::get_singleton(), &CanvasItemEditor::update_viewport));
tools_settings->add_child(picker_button);
viewport_shortcut_buttons.push_back(picker_button);
@ -2272,7 +2272,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
erase_button->set_theme_type_variation("FlatButton");
erase_button->set_toggle_mode(true);
erase_button->set_shortcut(ED_SHORTCUT("tiles_editor/eraser", TTR("Eraser"), Key::E));
erase_button->set_tooltip_text(TTR("Alternatively use RMB to erase tiles."));
erase_button->set_tooltip(TTR("Alternatively use RMB to erase tiles."));
erase_button->connect("pressed", callable_mp(CanvasItemEditor::get_singleton(), &CanvasItemEditor::update_viewport));
tools_settings->add_child(erase_button);
viewport_shortcut_buttons.push_back(erase_button);
@ -2325,7 +2325,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
random_tile_toggle = memnew(Button);
random_tile_toggle->set_theme_type_variation("FlatButton");
random_tile_toggle->set_toggle_mode(true);
random_tile_toggle->set_tooltip_text(TTR("Place Random Tile"));
random_tile_toggle->set_tooltip(TTR("Place Random Tile"));
random_tile_toggle->connect("toggled", callable_mp(this, &LayeredTileMapLayerEditorTilesPlugin::_on_random_tile_checkbox_toggled));
tools_settings->add_child(random_tile_toggle);
@ -2333,7 +2333,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
scatter_controls_container = memnew(HBoxContainer);
scatter_label = memnew(Label);
scatter_label->set_tooltip_text(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_label->set_tooltip(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_label->set_text(TTR("Scattering:"));
scatter_controls_container->add_child(scatter_label);
@ -2341,7 +2341,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
scatter_spinbox->set_min(0.0);
scatter_spinbox->set_max(1000);
scatter_spinbox->set_step(0.001);
scatter_spinbox->set_tooltip_text(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_spinbox->set_tooltip(TTR("Modifies the chance of painting nothing instead of a randomly selected tile."));
scatter_spinbox->get_line_edit()->add_theme_constant_override("minimum_character_width", 4);
scatter_spinbox->connect("value_changed", callable_mp(this, &LayeredTileMapLayerEditorTilesPlugin::_on_scattering_spinbox_changed));
scatter_controls_container->add_child(scatter_spinbox);
@ -2367,8 +2367,8 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
missing_source_label->set_text(TTR("This LayeredTileMap's LayeredTileSet has no source configured. Go to the LayeredTileSet bottom panel to add one."));
missing_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
missing_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
missing_source_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
missing_source_label->set_align(Label::ALIGN_CENTER);
missing_source_label->set_valign(Label::VALIGN_CENTER);
missing_source_label->hide();
tiles_bottom_panel->add_child(missing_source_label);
@ -2390,7 +2390,7 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
source_sort_button = memnew(MenuButton);
source_sort_button->set_flat(false);
source_sort_button->set_theme_type_variation("FlatMenuButton");
source_sort_button->set_tooltip_text(TTR("Sort sources"));
source_sort_button->set_tooltip(TTR("Sort sources"));
PopupMenu *p = source_sort_button->get_popup();
p->connect("id_pressed", callable_mp(this, &LayeredTileMapLayerEditorTilesPlugin::_set_source_sort));
@ -2456,8 +2456,8 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
invalid_source_label->set_text(TTR("Invalid source selected."));
invalid_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
invalid_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
invalid_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
invalid_source_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
invalid_source_label->set_align(Label::ALIGN_CENTER);
invalid_source_label->set_valign(Label::VALIGN_CENTER);
invalid_source_label->hide();
atlas_sources_split_container->add_child(invalid_source_label);
@ -2483,8 +2483,8 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
patterns_help_label = memnew(Label);
patterns_help_label->set_text(TTR("Drag and drop or paste a LayeredTileMap selection here to store a pattern."));
patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
patterns_help_label->set_align(Label::ALIGN_CENTER);
patterns_help_label->set_anchors_and_margins_preset(Control::PRESET_CENTER);
patterns_item_list->add_child(patterns_help_label);
// Update.
@ -3832,7 +3832,7 @@ void LayeredTileMapLayerEditor::_tab_changed(int p_tab_id) {
}
// Graphical update.
tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw();
tabs_data[tabs_bar->get_current_tab()].panel->update();
CanvasItemEditor::get_singleton()->update_viewport();
}
@ -4214,7 +4214,7 @@ LayeredTileMapLayerEditor::LayeredTileMapLayerEditor() {
layers_selection_button = memnew(OptionButton);
layers_selection_button->set_custom_minimum_size(Size2(200, 0));
layers_selection_button->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
layers_selection_button->set_tooltip_text(TTR("LayeredTileMap Layers"));
layers_selection_button->set_tooltip(TTR("LayeredTileMap Layers"));
layers_selection_button->connect("item_selected", callable_mp(this, &LayeredTileMapLayerEditor::_layers_selection_item_selected));
tile_map_toolbar->add_child(layers_selection_button);
@ -4223,7 +4223,7 @@ LayeredTileMapLayerEditor::LayeredTileMapLayerEditor() {
toggle_highlight_selected_layer_button->set_toggle_mode(true);
toggle_highlight_selected_layer_button->set_pressed(true);
toggle_highlight_selected_layer_button->connect("toggled", callable_mp(this, &LayeredTileMapLayerEditor::_highlight_selected_layer_button_toggled));
toggle_highlight_selected_layer_button->set_tooltip_text(TTR("Highlight Selected LayeredTileMap Layer"));
toggle_highlight_selected_layer_button->set_tooltip(TTR("Highlight Selected LayeredTileMap Layer"));
tile_map_toolbar->add_child(toggle_highlight_selected_layer_button);
tile_map_toolbar->add_child(memnew(VSeparator));
@ -4232,7 +4232,7 @@ LayeredTileMapLayerEditor::LayeredTileMapLayerEditor() {
toggle_grid_button = memnew(Button);
toggle_grid_button->set_theme_type_variation("FlatButton");
toggle_grid_button->set_toggle_mode(true);
toggle_grid_button->set_tooltip_text(TTR("Toggle grid visibility."));
toggle_grid_button->set_tooltip(TTR("Toggle grid visibility."));
toggle_grid_button->connect("toggled", callable_mp(this, &LayeredTileMapLayerEditor::_on_grid_toggled));
tile_map_toolbar->add_child(toggle_grid_button);
@ -4248,8 +4248,8 @@ LayeredTileMapLayerEditor::LayeredTileMapLayerEditor() {
missing_tileset_label->set_text(TTR("The edited LayeredTileMap node has no LayeredTileSet resource.\nCreate or load a LayeredTileSet resource in the Tile Set property in the inspector."));
missing_tileset_label->set_h_size_flags(SIZE_EXPAND_FILL);
missing_tileset_label->set_v_size_flags(SIZE_EXPAND_FILL);
missing_tileset_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
missing_tileset_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
missing_tileset_label->set_align(Label::ALIGN_CENTER);
missing_tileset_label->set_valign(Label::VALIGN_CENTER);
missing_tileset_label->hide();
add_child(missing_tileset_label);

View File

@ -562,7 +562,7 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_id_label() {
if (selection.size() == 1) {
TileSelection selected = selection.front()->get();
tool_tile_id_label->set_text(vformat("%d, %s, %d", tile_set_atlas_source_id, selected.tile, selected.alternative));
tool_tile_id_label->set_tooltip_text(vformat(TTR("Selected tile:\nSource: %d\nAtlas coordinates: %s\nAlternative: %d"), tile_set_atlas_source_id, selected.tile, selected.alternative));
tool_tile_id_label->set_tooltip(vformat(TTR("Selected tile:\nSource: %d\nAtlas coordinates: %s\nAlternative: %d"), tile_set_atlas_source_id, selected.tile, selected.alternative));
tool_tile_id_label->show();
} else {
tool_tile_id_label->hide();
@ -664,8 +664,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataTextureOriginEditor *tile_data_texture_origin_editor = memnew(TileDataTextureOriginEditor);
tile_data_texture_origin_editor->hide();
tile_data_texture_origin_editor->setup_property_editor(Variant::VECTOR2I, "texture_origin");
tile_data_texture_origin_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_texture_origin_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_texture_origin_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_texture_origin_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["texture_origin"] = tile_data_texture_origin_editor;
}
@ -674,8 +674,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataDefaultEditor *tile_data_modulate_editor = memnew(TileDataDefaultEditor());
tile_data_modulate_editor->hide();
tile_data_modulate_editor->setup_property_editor(Variant::COLOR, "modulate", "", Color(1.0, 1.0, 1.0, 1.0));
tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_modulate_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["modulate"] = tile_data_modulate_editor;
}
@ -684,8 +684,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataDefaultEditor *tile_data_z_index_editor = memnew(TileDataDefaultEditor());
tile_data_z_index_editor->hide();
tile_data_z_index_editor->setup_property_editor(Variant::INT, "z_index");
tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_z_index_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["z_index"] = tile_data_z_index_editor;
}
@ -694,8 +694,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataYSortEditor *tile_data_y_sort_editor = memnew(TileDataYSortEditor);
tile_data_y_sort_editor->hide();
tile_data_y_sort_editor->setup_property_editor(Variant::INT, "y_sort_origin");
tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_y_sort_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["y_sort_origin"] = tile_data_y_sort_editor;
}
@ -705,8 +705,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataOcclusionShapeEditor *tile_data_occlusion_shape_editor = memnew(TileDataOcclusionShapeEditor());
tile_data_occlusion_shape_editor->hide();
tile_data_occlusion_shape_editor->set_occlusion_layer(i);
tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_occlusion_shape_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors[vformat("occlusion_layer_%d", i)] = tile_data_occlusion_shape_editor;
}
}
@ -720,8 +720,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
if (!tile_data_editors.has("terrain_set")) {
TileDataTerrainsEditor *tile_data_terrains_editor = memnew(TileDataTerrainsEditor);
tile_data_terrains_editor->hide();
tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_terrains_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["terrain_set"] = tile_data_terrains_editor;
}
@ -731,8 +731,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor());
tile_data_probability_editor->hide();
tile_data_probability_editor->setup_property_editor(Variant::REAL, "probability", "", 1.0);
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors["probability"] = tile_data_probability_editor;
}
@ -746,8 +746,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataCollisionEditor *tile_data_collision_editor = memnew(TileDataCollisionEditor());
tile_data_collision_editor->hide();
tile_data_collision_editor->set_physics_layer(i);
tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_collision_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors[vformat("physics_layer_%d", i)] = tile_data_collision_editor;
}
}
@ -761,7 +761,7 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
item->set_icon(0, get_editor_theme_icon("Info"));
item->set_icon_modulate(0, disabled_color);
item->set_text(0, TTR("No physics layers"));
item->set_tooltip_text(0, TTR("Create and customize physics layers in the inspector of the LayeredTileSet resource."));
item->set_tooltip(0, TTR("Create and customize physics layers in the inspector of the LayeredTileSet resource."));
item->set_selectable(0, false);
item->set_custom_color(0, disabled_color);
}
@ -774,8 +774,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataNavigationEditor *tile_data_navigation_editor = memnew(TileDataNavigationEditor());
tile_data_navigation_editor->hide();
tile_data_navigation_editor->set_navigation_layer(i);
tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_navigation_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors[vformat("navigation_layer_%d", i)] = tile_data_navigation_editor;
}
}
@ -789,7 +789,7 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
item->set_icon(0, get_editor_theme_icon("Info"));
item->set_icon_modulate(0, disabled_color);
item->set_text(0, TTR("No navigation layers"));
item->set_tooltip_text(0, TTR("Create and customize navigation layers in the inspector of the LayeredTileSet resource."));
item->set_tooltip(0, TTR("Create and customize navigation layers in the inspector of the LayeredTileSet resource."));
item->set_selectable(0, false);
item->set_custom_color(0, disabled_color);
}
@ -817,8 +817,8 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
TileDataDefaultEditor *tile_data_custom_data_editor = memnew(TileDataDefaultEditor());
tile_data_custom_data_editor->hide();
tile_data_custom_data_editor->setup_property_editor(prop_type, editor_name, prop_name);
tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::update));
tile_data_custom_data_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::update));
tile_data_editors[editor_name] = tile_data_custom_data_editor;
}
}
@ -832,7 +832,7 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
item->set_icon(0, get_editor_theme_icon("Info"));
item->set_icon_modulate(0, disabled_color);
item->set_text(0, TTR("No custom data layers"));
item->set_tooltip_text(0, TTR("Create and customize custom data layers in the inspector of the LayeredTileSet resource."));
item->set_tooltip(0, TTR("Create and customize custom data layers in the inspector of the LayeredTileSet resource."));
item->set_selectable(0, false);
item->set_custom_color(0, disabled_color);
}
@ -957,10 +957,10 @@ void LayeredTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed(
void LayeredTileSetAtlasSourceEditor::_tile_data_editors_tree_selected() {
callable_mp((Window *)tile_data_editors_popup, &Window::hide).call_deferred();
_update_current_tile_data_editor();
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
}
void LayeredTileSetAtlasSourceEditor::_update_atlas_view() {
@ -1014,11 +1014,11 @@ void LayeredTileSetAtlasSourceEditor::_update_atlas_view() {
tile_atlas_view->set_padding(Side::SIDE_RIGHT, texture_region_base_size_min);
// Redraw everything.
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
// Synchronize atlas view.
LayeredTilesEditorUtils::get_singleton()->synchronize_atlas_view(tile_atlas_view);
@ -1049,14 +1049,14 @@ void LayeredTileSetAtlasSourceEditor::_update_toolbar() {
void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_mouse_exited() {
hovered_base_tile_coords = LayeredTileSetSource::INVALID_ATLAS_COORDS;
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
tile_atlas_view->update();
}
void LayeredTileSetAtlasSourceEditor::_tile_atlas_view_transform_changed() {
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
}
void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEvent> &p_event) {
@ -1071,11 +1071,11 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
// Update only what's needed.
tile_set_changed_needs_update = false;
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
return;
} else {
// Handle the event.
@ -1190,11 +1190,11 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
}
// Redraw for the hovered tile.
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
return;
}
@ -1336,11 +1336,11 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
// Left click released.
_end_dragging();
}
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
return;
} else if (mb->get_button_index() == MouseButton::RIGHT) {
// Right click pressed.
@ -1351,11 +1351,11 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
// Right click released.
_end_dragging();
}
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
return;
}
}
@ -1923,20 +1923,20 @@ void LayeredTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const
if (current_tile_data_editor) {
current_tile_data_editor->forward_painting_alternatives_gui_input(tile_atlas_view, tile_set_atlas_source, p_event);
}
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_view->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
tile_atlas_view->update();
return;
}
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
if (drag_type == DRAG_TYPE_MAY_POPUP_MENU) {
if (Vector2(drag_start_mouse_pos).distance_to(alternative_tiles_control->get_local_mouse_position()) > 5.0 * EDSCALE) {
@ -1993,19 +1993,19 @@ void LayeredTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const
drag_type = DRAG_TYPE_NONE;
}
}
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
}
}
void LayeredTileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
hovered_alternative_tile_coords = Vector3i(LayeredTileSetSource::INVALID_ATLAS_COORDS.x, LayeredTileSetSource::INVALID_ATLAS_COORDS.y, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
tile_atlas_control->queue_redraw();
tile_atlas_control_unscaled->queue_redraw();
alternative_tiles_control->queue_redraw();
alternative_tiles_control_unscaled->queue_redraw();
tile_atlas_control->update();
tile_atlas_control_unscaled->update();
alternative_tiles_control->update();
alternative_tiles_control_unscaled->update();
}
void LayeredTileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
@ -2529,7 +2529,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
tool_setup_atlas_source_button->set_toggle_mode(true);
tool_setup_atlas_source_button->set_pressed(true);
tool_setup_atlas_source_button->set_button_group(tools_button_group);
tool_setup_atlas_source_button->set_tooltip_text(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing)."));
tool_setup_atlas_source_button->set_tooltip(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing)."));
toolbox->add_child(tool_setup_atlas_source_button);
tool_select_button = memnew(Button);
@ -2538,7 +2538,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
tool_select_button->set_toggle_mode(true);
tool_select_button->set_pressed(false);
tool_select_button->set_button_group(tools_button_group);
tool_select_button->set_tooltip_text(TTR("Select tiles."));
tool_select_button->set_tooltip(TTR("Select tiles."));
toolbox->add_child(tool_select_button);
tool_paint_button = memnew(Button);
@ -2546,7 +2546,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
tool_paint_button->set_theme_type_variation("FlatButton");
tool_paint_button->set_toggle_mode(true);
tool_paint_button->set_button_group(tools_button_group);
tool_paint_button->set_tooltip_text(TTR("Paint properties."));
tool_paint_button->set_tooltip(TTR("Paint properties."));
toolbox->add_child(tool_paint_button);
// Tile inspector.
@ -2563,7 +2563,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
tile_inspector_no_tile_selected_label = memnew(Label);
tile_inspector_no_tile_selected_label->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
tile_inspector_no_tile_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
tile_inspector_no_tile_selected_label->set_align(Label::ALIGN_CENTER);
tile_inspector_no_tile_selected_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
tile_inspector_no_tile_selected_label->set_text(TTR("No tiles selected.\nSelect one or more tiles from the palette to edit its properties."));
middle_vbox_container->add_child(tile_inspector_no_tile_selected_label);
@ -2593,7 +2593,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
tile_data_editors_tree = memnew(Tree);
tile_data_editors_tree->set_hide_root(true);
tile_data_editors_tree->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
tile_data_editors_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE);
tile_data_editors_tree->set_h_scroll_enabled(false);
tile_data_editors_tree->set_v_scroll_enabled(false);
tile_data_editors_tree->connect("item_selected", callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_data_editors_tree_selected));
@ -2643,7 +2643,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
outside_tiles_warning = memnew(TextureRect);
outside_tiles_warning->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
outside_tiles_warning->set_tooltip_text(vformat(TTR("The current atlas source has tiles outside the texture.\nYou can clear it using \"%s\" option in the 3 dots menu."), TTR("Remove Tiles Outside the Texture")));
outside_tiles_warning->set_tooltip(vformat(TTR("The current atlas source has tiles outside the texture.\nYou can clear it using \"%s\" option in the 3 dots menu."), TTR("Remove Tiles Outside the Texture")));
outside_tiles_warning->hide();
tool_settings->add_child(outside_tiles_warning);
@ -2684,7 +2684,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
help_label = memnew(Label(TTR("Hold Shift to create big tiles.")));
tile_create_help->add_child(help_label);
tile_create_help->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT, Control::PRESET_MODE_MINSIZE);
tile_create_help->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT, Control::PRESET_MODE_MINSIZE);
Vector2 pos = tile_create_help->get_position();
pos.y -= 8 * EDSCALE;
tile_create_help->set_position(pos);

View File

@ -810,7 +810,7 @@ LayeredTileSetEditor::LayeredTileSetEditor() {
VBoxContainer *main_vb = memnew(VBoxContainer);
add_child(main_vb);
main_vb->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
main_vb->set_anchors_and_margins_preset(PRESET_WIDE);
// TabBar.
tabs_bar = memnew(TabBar);
@ -844,7 +844,7 @@ LayeredTileSetEditor::LayeredTileSetEditor() {
source_sort_button = memnew(MenuButton);
source_sort_button->set_flat(false);
source_sort_button->set_theme_type_variation("FlatButton");
source_sort_button->set_tooltip_text(TTR("Sort Sources"));
source_sort_button->set_tooltip(TTR("Sort Sources"));
PopupMenu *p = source_sort_button->get_popup();
p->connect("id_pressed", callable_mp(this, &LayeredTileSetEditor::_set_source_sort));
@ -912,8 +912,8 @@ LayeredTileSetEditor::LayeredTileSetEditor() {
no_source_selected_label->set_text(TTR("No LayeredTileSet source selected. Select or create a LayeredTileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list."));
no_source_selected_label->set_h_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_v_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
no_source_selected_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
no_source_selected_label->set_align(Label::ALIGN_CENTER);
no_source_selected_label->set_valign(Label::VALIGN_CENTER);
split_container_right_side->add_child(no_source_selected_label);
// Atlases editor.
@ -948,14 +948,14 @@ LayeredTileSetEditor::LayeredTileSetEditor() {
patterns_help_label = memnew(Label);
patterns_help_label->set_text(TTR("Add new patterns in the LayeredTileMap editing mode."));
patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
patterns_help_label->set_align(Label::ALIGN_CENTER);
patterns_help_label->set_anchors_and_margins_preset(Control::PRESET_CENTER);
patterns_item_list->add_child(patterns_help_label);
// Expanded editor
expanded_area = memnew(PanelContainer);
add_child(expanded_area);
expanded_area->set_anchors_and_offsets_preset(PRESET_LEFT_WIDE);
expanded_area->set_anchors_and_margins_preset(PRESET_LEFT_WIDE);
expanded_area->hide();
// Registers UndoRedo inspector callback.

View File

@ -1053,8 +1053,8 @@ void LayeredTileMap::_bind_methods() {
PropertyInfo(Variant::VECTOR2I, "coords"),
PropertyInfo(Variant::OBJECT, "tile_data", PROPERTY_HINT_RESOURCE_TYPE, "LayeredTileData")));
ClassDB::bind_method(D_METHOD("use_tile_data_runtime_update", "layer", "coords"), &LayeredTileMap::use_tile_data_runtime_update);
ClassDB::bind_method(D_METHOD("tile_data_runtime_update", "layer", "coords", "tile_data"), &LayeredTileMap::tile_data_runtime_update);
//ClassDB::bind_method(D_METHOD("use_tile_data_runtime_update", "layer", "coords"), &LayeredTileMap::use_tile_data_runtime_update);
//ClassDB::bind_method(D_METHOD("tile_data_runtime_update", "layer", "coords", "tile_data"), &LayeredTileMap::tile_data_runtime_update);
ClassDB::bind_method(D_METHOD("_emit_changed"), &LayeredTileMap::_emit_changed);

View File

@ -1416,8 +1416,6 @@ void LayeredTileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_c
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
if (atlas_source) {
bool ret = false;
if (p_use_tilemap_for_runtime) {
// Compatibility with LayeredTileMap.
if (tile_map_node->use_tile_data_runtime_update(layer_index_in_tile_map_node, r_cell_data.coords)) {
@ -1783,8 +1781,8 @@ void LayeredTileMapLayer::_bind_methods() {
PropertyInfo(Variant::VECTOR2I, "coords"),
PropertyInfo(Variant::OBJECT, "tile_data", PROPERTY_HINT_RESOURCE_TYPE, "LayeredTileData")));
ClassDB::bind_method(D_METHOD("use_tile_data_runtime_update", "coords"), &LayeredTileMapLayer::use_tile_data_runtime_update);
ClassDB::bind_method(D_METHOD("tile_data_runtime_update", "coords", "tile_data"), &LayeredTileMapLayer::tile_data_runtime_update);
//ClassDB::bind_method(D_METHOD("use_tile_data_runtime_update", "coords"), &LayeredTileMapLayer::use_tile_data_runtime_update);
//ClassDB::bind_method(D_METHOD("tile_data_runtime_update", "coords", "tile_data"), &LayeredTileMapLayer::tile_data_runtime_update_bind);
ClassDB::bind_method(D_METHOD("_deferred_internal_update"), &LayeredTileMapLayer::_deferred_internal_update);
ClassDB::bind_method(D_METHOD("_renamed"), &LayeredTileMapLayer::_renamed);

View File

@ -41,6 +41,8 @@
#include "scene/resources/texture.h"
#include "servers/navigation_2d_server.h"
#include "core/object/method_bind_ext.gen.inc"
/////////////////////////////// LayeredTileMapPattern //////////////////////////////////////
void LayeredTileMapPattern::_set_tile_data(const Vector<int> &p_data) {
@ -408,7 +410,7 @@ void LayeredTileSet::_update_terrains_cache() {
// Organizes tiles into structures.
per_terrain_pattern_tiles.resize(terrain_sets.size());
for (int i = 0; i < per_terrain_pattern_tiles.size(); ++i) {
for (uint32_t i = 0; i < per_terrain_pattern_tiles.size(); ++i) {
per_terrain_pattern_tiles[i].clear();
}
@ -5734,8 +5736,8 @@ void LayeredTileSetAtlasSource::_update_padded_texture() {
padded_texture->disconnect(CoreStringNames::get_singleton()->changed, this, "_queue_update_padded_texture");
}
padded_texture = Ref<Texture>();
padded_normal_texture = Ref<Texture>();
padded_texture.unref();
padded_normal_texture.unref();
if (texture.is_null()) {
return;
@ -5747,14 +5749,10 @@ void LayeredTileSetAtlasSource::_update_padded_texture() {
if (texture.is_valid()) {
padded_texture = _create_padded_image_texture(texture);
} else {
padded_texture.instance();
}
if (normal_texture.is_valid()) {
padded_normal_texture = _create_padded_image_texture(normal_texture);
} else {
padded_normal_texture.instance();
}
padded_texture->connect(CoreStringNames::get_singleton()->changed, this, "_queue_update_padded_texture");