mirror of
https://github.com/Relintai/tile_map_backport.git
synced 2024-11-05 10:11:16 +01:00
Work on tile set atlas source editor.
This commit is contained in:
parent
a1097604a8
commit
471a722ee6
@ -47,6 +47,7 @@
|
|||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "../geometry_2d.h"
|
#include "../geometry_2d.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
|
#include "core/os/input.h"
|
||||||
|
|
||||||
void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::set_id(int p_id) {
|
void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::set_id(int p_id) {
|
||||||
ERR_FAIL_COND(p_id < 0);
|
ERR_FAIL_COND(p_id < 0);
|
||||||
@ -138,7 +139,7 @@ void RTileSetAtlasSourceEditor::RTileSetAtlasSourceProxyObject::edit(Ref<RTileSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_property_list_changed();
|
property_list_changed_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Proxy object used by the tile inspector --
|
// -- Proxy object used by the tile inspector --
|
||||||
@ -173,7 +174,7 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n
|
|||||||
} else if (p_name == "size_in_atlas") {
|
} else if (p_name == "size_in_atlas") {
|
||||||
Vector2i as_vector2i = Vector2i(p_value);
|
Vector2i as_vector2i = Vector2i(p_value);
|
||||||
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, as_vector2i, tile_set_atlas_source->get_tile_animation_columns(coords), tile_set_atlas_source->get_tile_animation_separation(coords), tile_set_atlas_source->get_tile_animation_frames_count(coords), coords);
|
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(coords, as_vector2i, tile_set_atlas_source->get_tile_animation_columns(coords), tile_set_atlas_source->get_tile_animation_separation(coords), tile_set_atlas_source->get_tile_animation_frames_count(coords), coords);
|
||||||
ERR_FAIL_COND_V_EDMSG(!has_room_for_tile, false, "Invalid size or not enough room in the atlas for the tile.");
|
ERR_FAIL_COND_V_MSG(!has_room_for_tile, false, "Invalid size or not enough room in the atlas for the tile.");
|
||||||
tile_set_atlas_source->move_tile_in_atlas(coords, RTileSetSource::INVALID_ATLAS_COORDS, as_vector2i);
|
tile_set_atlas_source->move_tile_in_atlas(coords, RTileSetSource::INVALID_ATLAS_COORDS, as_vector2i);
|
||||||
emit_signal(("changed"), "size_in_atlas");
|
emit_signal(("changed"), "size_in_atlas");
|
||||||
return true;
|
return true;
|
||||||
@ -182,7 +183,7 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n
|
|||||||
if (p_name == "alternative_id") {
|
if (p_name == "alternative_id") {
|
||||||
int as_int = int(p_value);
|
int as_int = int(p_value);
|
||||||
ERR_FAIL_COND_V(as_int < 0, false);
|
ERR_FAIL_COND_V(as_int < 0, false);
|
||||||
ERR_FAIL_COND_V_MSG(tile_set_atlas_source->has_alternative_tile(coords, as_int), false, vformat("Cannot change alternative tile ID. Another alternative exists with id %d for tile at coords %s.", as_int, coords));
|
ERR_FAIL_COND_V_MSG(tile_set_atlas_source->has_alternative_tile(coords, as_int), false, vformat("Cannot change alternative tile ID. Another alternative exists with id %d for tile at coords %s.", as_int, Vector2(coords)));
|
||||||
|
|
||||||
if (tiles_set_atlas_source_editor->selection.front()->get().alternative == alternative) {
|
if (tiles_set_atlas_source_editor->selection.front()->get().alternative == alternative) {
|
||||||
tiles_set_atlas_source_editor->selection.clear();
|
tiles_set_atlas_source_editor->selection.clear();
|
||||||
@ -203,8 +204,9 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n
|
|||||||
// Animation.
|
// Animation.
|
||||||
// Check if all tiles have an alternative_id of 0.
|
// Check if all tiles have an alternative_id of 0.
|
||||||
bool all_alternatve_id_zero = true;
|
bool all_alternatve_id_zero = true;
|
||||||
for (TileSelection tile : tiles) {
|
|
||||||
if (tile.alternative != 0) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
|
if (tile->get().alternative != 0) {
|
||||||
all_alternatve_id_zero = false;
|
all_alternatve_id_zero = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -213,53 +215,53 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n
|
|||||||
if (all_alternatve_id_zero) {
|
if (all_alternatve_id_zero) {
|
||||||
Vector<String> components = String(p_name).split("/", true, 2);
|
Vector<String> components = String(p_name).split("/", true, 2);
|
||||||
if (p_name == "animation_columns") {
|
if (p_name == "animation_columns") {
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), p_value, tile_set_atlas_source->get_tile_animation_separation(tile.tile), tile_set_atlas_source->get_tile_animation_frames_count(tile.tile), tile.tile);
|
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile->get().tile, tile_set_atlas_source->get_tile_size_in_atlas(tile->get().tile), p_value, tile_set_atlas_source->get_tile_animation_separation(tile->get().tile), tile_set_atlas_source->get_tile_animation_frames_count(tile->get().tile), tile->get().tile);
|
||||||
if (!has_room_for_tile) {
|
if (!has_room_for_tile) {
|
||||||
ERR_PRINT("No room for tile");
|
ERR_PRINT("No room for tile");
|
||||||
} else {
|
} else {
|
||||||
tile_set_atlas_source->set_tile_animation_columns(tile.tile, p_value);
|
tile_set_atlas_source->set_tile_animation_columns(tile->get().tile, p_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit_signal(("changed"), "animation_columns");
|
emit_signal(("changed"), "animation_columns");
|
||||||
return true;
|
return true;
|
||||||
} else if (p_name == "animation_separation") {
|
} else if (p_name == "animation_separation") {
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), tile_set_atlas_source->get_tile_animation_columns(tile.tile), p_value, tile_set_atlas_source->get_tile_animation_frames_count(tile.tile), tile.tile);
|
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile->get().tile, tile_set_atlas_source->get_tile_size_in_atlas(tile->get().tile), tile_set_atlas_source->get_tile_animation_columns(tile->get().tile), p_value, tile_set_atlas_source->get_tile_animation_frames_count(tile->get().tile), tile->get().tile);
|
||||||
if (!has_room_for_tile) {
|
if (!has_room_for_tile) {
|
||||||
ERR_PRINT("No room for tile");
|
ERR_PRINT("No room for tile");
|
||||||
} else {
|
} else {
|
||||||
tile_set_atlas_source->set_tile_animation_separation(tile.tile, p_value);
|
tile_set_atlas_source->set_tile_animation_separation(tile->get().tile, p_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit_signal(("changed"), "animation_separation");
|
emit_signal(("changed"), "animation_separation");
|
||||||
return true;
|
return true;
|
||||||
} else if (p_name == "animation_speed") {
|
} else if (p_name == "animation_speed") {
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
tile_set_atlas_source->set_tile_animation_speed(tile.tile, p_value);
|
tile_set_atlas_source->set_tile_animation_speed(tile->get().tile, p_value);
|
||||||
}
|
}
|
||||||
emit_signal(("changed"), "animation_speed");
|
emit_signal(("changed"), "animation_speed");
|
||||||
return true;
|
return true;
|
||||||
} else if (p_name == "animation_frames_count") {
|
} else if (p_name == "animation_frames_count") {
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile.tile, tile_set_atlas_source->get_tile_size_in_atlas(tile.tile), tile_set_atlas_source->get_tile_animation_columns(tile.tile), tile_set_atlas_source->get_tile_animation_separation(tile.tile), p_value, tile.tile);
|
bool has_room_for_tile = tile_set_atlas_source->has_room_for_tile(tile->get().tile, tile_set_atlas_source->get_tile_size_in_atlas(tile->get().tile), tile_set_atlas_source->get_tile_animation_columns(tile->get().tile), tile_set_atlas_source->get_tile_animation_separation(tile->get().tile), p_value, tile->get().tile);
|
||||||
if (!has_room_for_tile) {
|
if (!has_room_for_tile) {
|
||||||
ERR_PRINT("No room for tile");
|
ERR_PRINT("No room for tile");
|
||||||
} else {
|
} else {
|
||||||
tile_set_atlas_source->set_tile_animation_frames_count(tile.tile, p_value);
|
tile_set_atlas_source->set_tile_animation_frames_count(tile->get().tile, p_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notify_property_list_changed();
|
property_list_changed_notify();
|
||||||
emit_signal(("changed"), "animation_separation");
|
emit_signal(("changed"), "animation_separation");
|
||||||
return true;
|
return true;
|
||||||
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
|
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_integer()) {
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
int frame = components[0].trim_prefix("animation_frame_").to_int();
|
int frame = components[0].trim_prefix("animation_frame_").to_int();
|
||||||
if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(tile.tile)) {
|
if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(tile->get().tile)) {
|
||||||
ERR_PRINT(vformat("No tile animation frame with index %d", frame));
|
ERR_PRINT(vformat("No tile animation frame with index %d", frame));
|
||||||
} else {
|
} else {
|
||||||
if (components[1] == "duration") {
|
if (components[1] == "duration") {
|
||||||
tile_set_atlas_source->set_tile_animation_frame_duration(tile.tile, frame, p_value);
|
tile_set_atlas_source->set_tile_animation_frame_duration(tile->get().tile, frame, p_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +276,7 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_n
|
|||||||
const int &alternative = E->get().alternative;
|
const int &alternative = E->get().alternative;
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
ERR_FAIL_COND_V(!tile_data, false);
|
ERR_FAIL_COND_V(!tile_data, false);
|
||||||
tile_data->set(p_name, p_value, &valid);
|
tile_data->set(p_name, p_value, &valid);
|
||||||
|
|
||||||
@ -318,8 +320,8 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_n
|
|||||||
// Animation.
|
// Animation.
|
||||||
// Check if all tiles have an alternative_id of 0.
|
// Check if all tiles have an alternative_id of 0.
|
||||||
bool all_alternatve_id_zero = true;
|
bool all_alternatve_id_zero = true;
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
if (tile.alternative != 0) {
|
if (tile->get().alternative != 0) {
|
||||||
all_alternatve_id_zero = false;
|
all_alternatve_id_zero = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -359,7 +361,7 @@ bool RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get(const StringName &p_n
|
|||||||
const Vector2i &coords = E->get().tile;
|
const Vector2i &coords = E->get().tile;
|
||||||
const int &alternative = E->get().alternative;
|
const int &alternative = E->get().alternative;
|
||||||
|
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
ERR_FAIL_COND_V(!tile_data, false);
|
ERR_FAIL_COND_V(!tile_data, false);
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
@ -380,8 +382,8 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pr
|
|||||||
// ID and size related properties.
|
// ID and size related properties.
|
||||||
if (tiles.size() == 1) {
|
if (tiles.size() == 1) {
|
||||||
if (tiles.front()->get().alternative == 0) {
|
if (tiles.front()->get().alternative == 0) {
|
||||||
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "atlas_coords", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::VECTOR2, "atlas_coords", PROPERTY_HINT_NONE, ""));
|
||||||
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size_in_atlas", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size_in_atlas", PROPERTY_HINT_NONE, ""));
|
||||||
} else {
|
} else {
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "alternative_id", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::INT, "alternative_id", PROPERTY_HINT_NONE, ""));
|
||||||
}
|
}
|
||||||
@ -390,8 +392,8 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pr
|
|||||||
// Animation.
|
// Animation.
|
||||||
// Check if all tiles have an alternative_id of 0.
|
// Check if all tiles have an alternative_id of 0.
|
||||||
bool all_alternatve_id_zero = true;
|
bool all_alternatve_id_zero = true;
|
||||||
for (TileSelection tile : tiles) {
|
for (Set<TileSelection>::Element *tile = tiles.front(); tile; tile = tile->next()) {
|
||||||
if (tile.alternative != 0) {
|
if (tile->get().alternative != 0) {
|
||||||
all_alternatve_id_zero = false;
|
all_alternatve_id_zero = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -400,15 +402,15 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pr
|
|||||||
if (all_alternatve_id_zero) {
|
if (all_alternatve_id_zero) {
|
||||||
p_list->push_back(PropertyInfo(Variant::NIL, "Animation", PROPERTY_HINT_NONE, "animation_", PROPERTY_USAGE_GROUP));
|
p_list->push_back(PropertyInfo(Variant::NIL, "Animation", PROPERTY_HINT_NONE, "animation_", PROPERTY_USAGE_GROUP));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "animation_columns", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::INT, "animation_columns", PROPERTY_HINT_NONE, ""));
|
||||||
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "animation_separation", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::VECTOR2, "animation_separation", PROPERTY_HINT_NONE, ""));
|
||||||
p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_speed", PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::REAL, "animation_speed", PROPERTY_HINT_NONE, ""));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT, "animation_frames_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY, "Frames,animation_frame_"));
|
p_list->push_back(PropertyInfo(Variant::INT, "animation_frames_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR, "Frames,animation_frame_"));
|
||||||
// Not optimal, but returns value for the first tile. This is similar to what MultiNodeEdit does.
|
// Not optimal, but returns value for the first tile. This is similar to what MultiNodeEdit does.
|
||||||
if (tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile) == 1) {
|
if (tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile) == 1) {
|
||||||
p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_frame_0/duration", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY));
|
p_list->push_back(PropertyInfo(Variant::REAL, "animation_frame_0/duration", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile); i++) {
|
for (int i = 0; i < tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile); i++) {
|
||||||
p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("animation_frame_%d/duration", i), PROPERTY_HINT_NONE, ""));
|
p_list->push_back(PropertyInfo(Variant::REAL, vformat("animation_frame_%d/duration", i), PROPERTY_HINT_NONE, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +434,7 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pr
|
|||||||
const Vector2i &coords = E->get().tile;
|
const Vector2i &coords = E->get().tile;
|
||||||
const int &alternative = E->get().alternative;
|
const int &alternative = E->get().alternative;
|
||||||
|
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
ERR_FAIL_COND(!tile_data);
|
ERR_FAIL_COND(!tile_data);
|
||||||
|
|
||||||
List<PropertyInfo> list;
|
List<PropertyInfo> list;
|
||||||
@ -465,16 +467,16 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add only properties that are common to all tiles.
|
// Add only properties that are common to all tiles.
|
||||||
for (const PLData *E : data_list) {
|
for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) {
|
||||||
if (E->uses == tiles.size()) {
|
if (E->get()->uses == tiles.size()) {
|
||||||
p_list->push_back(E->property_info);
|
p_list->push_back(E->get()->property_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
|
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *p_tile_set_atlas_source, Set<TileSelection> p_tiles) {
|
||||||
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
ERR_FAIL_COND(!p_tile_set_atlas_source);
|
||||||
ERR_FAIL_COND(p_tiles.is_empty());
|
ERR_FAIL_COND(p_tiles.empty());
|
||||||
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
|
for (Set<TileSelection>::Element *E = p_tiles.front(); E; E = E->next()) {
|
||||||
ERR_FAIL_COND(E->get().tile == RTileSetSource::INVALID_ATLAS_COORDS);
|
ERR_FAIL_COND(E->get().tile == RTileSetSource::INVALID_ATLAS_COORDS);
|
||||||
ERR_FAIL_COND(E->get().alternative < 0);
|
ERR_FAIL_COND(E->get().alternative < 0);
|
||||||
@ -486,7 +488,7 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *
|
|||||||
const int &alternative = E->get().alternative;
|
const int &alternative = E->get().alternative;
|
||||||
|
|
||||||
if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
|
if (tile_set_atlas_source && tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
if (tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
|
if (tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
|
||||||
tile_data->disconnect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
|
tile_data->disconnect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
|
||||||
}
|
}
|
||||||
@ -502,14 +504,14 @@ void RTileSetAtlasSourceEditor::AtlasTileProxyObject::edit(RTileSetAtlasSource *
|
|||||||
const int &alternative = E->get().alternative;
|
const int &alternative = E->get().alternative;
|
||||||
|
|
||||||
if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
|
if (tile_set_atlas_source->has_tile(coords) && tile_set_atlas_source->has_alternative_tile(coords, alternative)) {
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
if (!tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
|
if (!tile_data->is_connected(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed))) {
|
||||||
tile_data->connect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
|
tile_data->connect(CoreStringNames::get_singleton()->property_list_changed, callable_mp((Object *)this, &Object::notify_property_list_changed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_property_list_changed();
|
property_list_changed_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() {
|
void RTileSetAtlasSourceEditor::AtlasTileProxyObject::_bind_methods() {
|
||||||
@ -525,7 +527,7 @@ void RTileSetAtlasSourceEditor::_inspector_property_selected(String p_property)
|
|||||||
void RTileSetAtlasSourceEditor::_update_tile_id_label() {
|
void RTileSetAtlasSourceEditor::_update_tile_id_label() {
|
||||||
if (selection.size() == 1) {
|
if (selection.size() == 1) {
|
||||||
TileSelection selected = selection.front()->get();
|
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_text(vformat("%d, %s, %d", tile_set_atlas_source_id, Vector2(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->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();
|
tool_tile_id_label->show();
|
||||||
} else {
|
} else {
|
||||||
@ -568,12 +570,12 @@ void RTileSetAtlasSourceEditor::_update_atlas_source_inspector() {
|
|||||||
void RTileSetAtlasSourceEditor::_update_tile_inspector() {
|
void RTileSetAtlasSourceEditor::_update_tile_inspector() {
|
||||||
// Update visibility.
|
// Update visibility.
|
||||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||||
if (!selection.is_empty()) {
|
if (!selection.empty()) {
|
||||||
tile_proxy_object->edit(tile_set_atlas_source, selection);
|
tile_proxy_object->edit(tile_set_atlas_source, selection);
|
||||||
}
|
}
|
||||||
tile_inspector_label->show();
|
tile_inspector_label->show();
|
||||||
tile_inspector->set_visible(!selection.is_empty());
|
tile_inspector->set_visible(!selection.empty());
|
||||||
tile_inspector_no_tile_selected_label->set_visible(selection.is_empty());
|
tile_inspector_no_tile_selected_label->set_visible(selection.empty());
|
||||||
} else {
|
} else {
|
||||||
tile_inspector_label->hide();
|
tile_inspector_label->hide();
|
||||||
tile_inspector->hide();
|
tile_inspector->hide();
|
||||||
@ -609,10 +611,10 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Theming.
|
// Theming.
|
||||||
tile_data_editors_tree->add_theme_constant_override("vseparation", 1);
|
tile_data_editors_tree->add_constant_override("vseparation", 1);
|
||||||
tile_data_editors_tree->add_theme_constant_override("hseparation", 3);
|
tile_data_editors_tree->add_constant_override("hseparation", 3);
|
||||||
|
|
||||||
Color group_color = get_theme_color(("prop_category"), ("Editor"));
|
Color group_color = get_color(("prop_category"), ("Editor"));
|
||||||
|
|
||||||
// List of editors.
|
// List of editors.
|
||||||
// --- Rendering ---
|
// --- Rendering ---
|
||||||
@ -734,7 +736,7 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() {
|
|||||||
// --- Custom Data ---
|
// --- Custom Data ---
|
||||||
ADD_TILE_DATA_EDITOR_GROUP("Custom Data");
|
ADD_TILE_DATA_EDITOR_GROUP("Custom Data");
|
||||||
for (int i = 0; i < tile_set->get_custom_data_layers_count(); i++) {
|
for (int i = 0; i < tile_set->get_custom_data_layers_count(); i++) {
|
||||||
if (tile_set->get_custom_data_name(i).is_empty()) {
|
if (tile_set->get_custom_data_name(i).empty()) {
|
||||||
ADD_TILE_DATA_EDITOR(group, vformat("Custom Data %d", i), vformat("custom_data_%d", i));
|
ADD_TILE_DATA_EDITOR(group, vformat("Custom Data %d", i), vformat("custom_data_%d", i));
|
||||||
} else {
|
} else {
|
||||||
ADD_TILE_DATA_EDITOR(group, tile_set->get_custom_data_name(i), vformat("custom_data_%d", i));
|
ADD_TILE_DATA_EDITOR(group, tile_set->get_custom_data_name(i), vformat("custom_data_%d", i));
|
||||||
@ -757,9 +759,9 @@ void RTileSetAtlasSourceEditor::_update_tile_data_editors() {
|
|||||||
#undef ADD_TILE_DATA_EDITOR
|
#undef ADD_TILE_DATA_EDITOR
|
||||||
|
|
||||||
// Add tile data editors as children.
|
// Add tile data editors as children.
|
||||||
for (KeyValue<String, RTileDataEditor *> &E : tile_data_editors) {
|
for (Map<String, RTileDataEditor *>::Element *E = tile_data_editors.front(); E; E = E->next()) {
|
||||||
// Tile Data Editor.
|
// Tile Data Editor.
|
||||||
RTileDataEditor *tile_data_editor = E.value;
|
RTileDataEditor *tile_data_editor = E->value();
|
||||||
if (!tile_data_editor->is_inside_tree()) {
|
if (!tile_data_editor->is_inside_tree()) {
|
||||||
tile_data_painting_editor_container->add_child(tile_data_editor);
|
tile_data_painting_editor_container->add_child(tile_data_editor);
|
||||||
}
|
}
|
||||||
@ -803,9 +805,9 @@ void RTileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide all editors but the current one.
|
// Hide all editors but the current one.
|
||||||
for (const KeyValue<String, RTileDataEditor *> &E : tile_data_editors) {
|
for (Map<String, RTileDataEditor *>::Element *E = tile_data_editors.front(); E; E = E->next()) {
|
||||||
E.value->hide();
|
E->value()->hide();
|
||||||
E.value->get_toolbar()->hide();
|
E->value()->get_toolbar()->hide();
|
||||||
}
|
}
|
||||||
if (tile_data_editors.has(property)) {
|
if (tile_data_editors.has(property)) {
|
||||||
current_tile_data_editor = tile_data_editors[property];
|
current_tile_data_editor = tile_data_editors[property];
|
||||||
@ -823,29 +825,29 @@ void RTileSetAtlasSourceEditor::_update_current_tile_data_editor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
||||||
if (!has_theme_icon(("arrow"), ("OptionButton"))) {
|
if (!has_icon(("arrow"), ("OptionButton"))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RID ci = tile_data_editor_dropdown_button->get_canvas_item();
|
RID ci = tile_data_editor_dropdown_button->get_canvas_item();
|
||||||
Ref<Texture> arrow = Control::get_theme_icon(("arrow"), ("OptionButton"));
|
Ref<Texture> arrow = Control::get_icon(("arrow"), ("OptionButton"));
|
||||||
Color clr = Color(1, 1, 1);
|
Color clr = Color(1, 1, 1);
|
||||||
if (get_theme_constant(("modulate_arrow"))) {
|
if (get_constant(("modulate_arrow"))) {
|
||||||
switch (tile_data_editor_dropdown_button->get_draw_mode()) {
|
switch (tile_data_editor_dropdown_button->get_draw_mode()) {
|
||||||
case BaseButton::DRAW_PRESSED:
|
case BaseButton::DRAW_PRESSED:
|
||||||
clr = get_theme_color(("font_pressed_color"));
|
clr = get_color(("font_pressed_color"));
|
||||||
break;
|
break;
|
||||||
case BaseButton::DRAW_HOVER:
|
case BaseButton::DRAW_HOVER:
|
||||||
clr = get_theme_color(("font_hover_color"));
|
clr = get_color(("font_hover_color"));
|
||||||
break;
|
break;
|
||||||
case BaseButton::DRAW_DISABLED:
|
case BaseButton::DRAW_DISABLED:
|
||||||
clr = get_theme_color(("font_disabled_color"));
|
clr = get_color(("font_disabled_color"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (tile_data_editor_dropdown_button->has_focus()) {
|
if (tile_data_editor_dropdown_button->has_focus()) {
|
||||||
clr = get_theme_color(("font_focus_color"));
|
clr = get_color(("font_focus_color"));
|
||||||
} else {
|
} else {
|
||||||
clr = get_theme_color(("font_color"));
|
clr = get_color(("font_color"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -854,9 +856,9 @@ void RTileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() {
|
|||||||
|
|
||||||
Point2 ofs;
|
Point2 ofs;
|
||||||
if (is_layout_rtl()) {
|
if (is_layout_rtl()) {
|
||||||
ofs = Point2(get_theme_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
ofs = Point2(get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
||||||
} else {
|
} else {
|
||||||
ofs = Point2(size.width - arrow->get_width() - get_theme_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
ofs = Point2(size.width - arrow->get_width() - get_constant(("arrow_margin"), ("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
||||||
}
|
}
|
||||||
arrow->draw(ci, ofs, clr);
|
arrow->draw(ci, ofs, clr);
|
||||||
}
|
}
|
||||||
@ -908,10 +910,10 @@ void RTileSetAtlasSourceEditor::_update_atlas_view() {
|
|||||||
alternative_tiles_control->add_child(button);
|
alternative_tiles_control->add_child(button);
|
||||||
button->set_flat(true);
|
button->set_flat(true);
|
||||||
button->set_icon(get_theme_icon(("Add"), ("EditorIcons")));
|
button->set_icon(get_theme_icon(("Add"), ("EditorIcons")));
|
||||||
button->add_theme_style_override("normal", memnew(StyleBoxEmpty));
|
button->add_style_override("normal", memnew(StyleBoxEmpty));
|
||||||
button->add_theme_style_override("hover", memnew(StyleBoxEmpty));
|
button->add_style_override("hover", memnew(StyleBoxEmpty));
|
||||||
button->add_theme_style_override("focus", memnew(StyleBoxEmpty));
|
button->add_style_override("focus", memnew(StyleBoxEmpty));
|
||||||
button->add_theme_style_override("pressed", memnew(StyleBoxEmpty));
|
button->add_style_override("pressed", memnew(StyleBoxEmpty));
|
||||||
button->connect("pressed", callable_mp(tile_set_atlas_source, &RTileSetAtlasSource::create_alternative_tile), varray(tile_id, RTileSetSource::INVALID_TILE_ALTERNATIVE));
|
button->connect("pressed", callable_mp(tile_set_atlas_source, &RTileSetAtlasSource::create_alternative_tile), varray(tile_id, RTileSetSource::INVALID_TILE_ALTERNATIVE));
|
||||||
button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min)));
|
button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min)));
|
||||||
button->set_expand_icon(true);
|
button->set_expand_icon(true);
|
||||||
@ -1142,13 +1144,13 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEve
|
|||||||
Ref<InputEventMouseButton> mb = p_event;
|
Ref<InputEventMouseButton> mb = p_event;
|
||||||
if (mb.is_valid()) {
|
if (mb.is_valid()) {
|
||||||
Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
|
Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
|
||||||
if (mb->get_button_index() == MouseButton::LEFT) {
|
if (mb->get_button_index() == BUTTON_LEFT) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
// Left click pressed.
|
// Left click pressed.
|
||||||
if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
|
if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
|
||||||
if (tools_settings_erase_button->is_pressed()) {
|
if (tools_settings_erase_button->is_pressed()) {
|
||||||
// Erasing
|
// Erasing
|
||||||
if (mb->is_ctrl_pressed() || mb->is_shift_pressed()) {
|
if (mb->get_control() || mb->get_shift()) {
|
||||||
// Remove tiles using rect.
|
// Remove tiles using rect.
|
||||||
|
|
||||||
// Setup the dragging info.
|
// Setup the dragging info.
|
||||||
@ -1174,7 +1176,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEve
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Creating
|
// Creating
|
||||||
if (mb->is_shift_pressed()) {
|
if (mb->get_shift()) {
|
||||||
// Create a big tile.
|
// Create a big tile.
|
||||||
Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
|
Vector2i coords = tile_atlas_view->get_atlas_tile_coords_at_pos(mouse_local_pos);
|
||||||
if (coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) {
|
if (coords != RTileSetSource::INVALID_ATLAS_COORDS && tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) {
|
||||||
@ -1187,7 +1189,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEve
|
|||||||
// Create a tile.
|
// Create a tile.
|
||||||
tile_set_atlas_source->create_tile(coords);
|
tile_set_atlas_source->create_tile(coords);
|
||||||
}
|
}
|
||||||
} else if (mb->is_ctrl_pressed()) {
|
} else if (mb->get_control()) {
|
||||||
// Create tiles using rect.
|
// Create tiles using rect.
|
||||||
drag_type = DRAG_TYPE_CREATE_TILES_USING_RECT;
|
drag_type = DRAG_TYPE_CREATE_TILES_USING_RECT;
|
||||||
drag_start_mouse_pos = mouse_local_pos;
|
drag_start_mouse_pos = mouse_local_pos;
|
||||||
@ -1261,7 +1263,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shift = mb->is_shift_pressed();
|
bool shift = mb->get_shift();
|
||||||
if (!shift && selection.size() == 1 && selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
|
if (!shift && selection.size() == 1 && selected.tile != RTileSetSource::INVALID_ATLAS_COORDS && selection.has(selected)) {
|
||||||
// Start move dragging.
|
// Start move dragging.
|
||||||
drag_type = DRAG_TYPE_MOVE_TILE;
|
drag_type = DRAG_TYPE_MOVE_TILE;
|
||||||
@ -1288,7 +1290,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<InputEve
|
|||||||
alternative_tiles_control_unscaled->update();
|
alternative_tiles_control_unscaled->update();
|
||||||
tile_atlas_view->update();
|
tile_atlas_view->update();
|
||||||
return;
|
return;
|
||||||
} else if (mb->get_button_index() == MouseButton::RIGHT) {
|
} else if (mb->get_button_index() == BUTTON_RIGHT) {
|
||||||
// Right click pressed.
|
// Right click pressed.
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
drag_type = DRAG_TYPE_MAY_POPUP_MENU;
|
drag_type = DRAG_TYPE_MAY_POPUP_MENU;
|
||||||
@ -1316,13 +1318,13 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E->get());
|
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", E->get());
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E->get());
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", E->get());
|
||||||
}
|
}
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
break;
|
break;
|
||||||
case DRAG_TYPE_CREATE_BIG_TILE:
|
case DRAG_TYPE_CREATE_BIG_TILE:
|
||||||
undo_redo->create_action(TTR("Create a tile"));
|
undo_redo->create_action(TTR("Create a tile"));
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
|
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", drag_current_tile);
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", drag_current_tile);
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
break;
|
break;
|
||||||
case DRAG_TYPE_REMOVE_TILES: {
|
case DRAG_TYPE_REMOVE_TILES: {
|
||||||
List<PropertyInfo> list;
|
List<PropertyInfo> list;
|
||||||
@ -1331,8 +1333,8 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
undo_redo->create_action(TTR("Remove tiles"));
|
undo_redo->create_action(TTR("Remove tiles"));
|
||||||
for (Set<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) {
|
for (Set<Vector2i>::Element *E = drag_modified_tiles.front(); E; E = E->next()) {
|
||||||
Vector2i coords = E->get();
|
Vector2i coords = E->get();
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", Vector2(coords));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", Vector2(coords));
|
||||||
if (per_tile.has(coords)) {
|
if (per_tile.has(coords)) {
|
||||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
||||||
String property = E_property->get()->name;
|
String property = E_property->get()->name;
|
||||||
@ -1355,8 +1357,8 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
for (int y = area.get_position().y; y < area.get_end().y; y++) {
|
for (int y = area.get_position().y; y < area.get_end().y; y++) {
|
||||||
Vector2i coords = Vector2i(x, y);
|
Vector2i coords = Vector2i(x, y);
|
||||||
if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) {
|
if (tile_set_atlas_source->get_tile_at_coords(coords) == RTileSetSource::INVALID_ATLAS_COORDS) {
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", Vector2(coords));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", Vector2(coords));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1385,8 +1387,8 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
undo_redo->add_do_method(this, "_set_selection_from_array", Array());
|
undo_redo->add_do_method(this, "_set_selection_from_array", Array());
|
||||||
for (Set<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) {
|
for (Set<Vector2i>::Element *E = to_delete.front(); E; E = E->next()) {
|
||||||
Vector2i coords = E->get();
|
Vector2i coords = E->get();
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", Vector2(coords));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", Vector2(coords));
|
||||||
if (per_tile.has(coords)) {
|
if (per_tile.has(coords)) {
|
||||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
||||||
String property = E_property->get()->name;
|
String property = E_property->get()->name;
|
||||||
@ -1407,10 +1409,10 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "move_tile_in_atlas", drag_current_tile, drag_start_tile_shape.position, drag_start_tile_shape.size);
|
undo_redo->add_undo_method(tile_set_atlas_source, "move_tile_in_atlas", drag_current_tile, drag_start_tile_shape.position, drag_start_tile_shape.size);
|
||||||
Array array;
|
Array array;
|
||||||
array.push_back(drag_start_tile_shape.position);
|
array.push_back(Point2(drag_start_tile_shape.position));
|
||||||
array.push_back(0);
|
array.push_back(0);
|
||||||
undo_redo->add_undo_method(this, "_set_selection_from_array", array);
|
undo_redo->add_undo_method(this, "_set_selection_from_array", array);
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DRAG_TYPE_RECT_SELECT: {
|
case DRAG_TYPE_RECT_SELECT: {
|
||||||
@ -1456,7 +1458,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
_update_tile_id_label();
|
_update_tile_id_label();
|
||||||
_update_current_tile_data_editor();
|
_update_current_tile_data_editor();
|
||||||
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
} break;
|
} break;
|
||||||
case DRAG_TYPE_MAY_POPUP_MENU: {
|
case DRAG_TYPE_MAY_POPUP_MENU: {
|
||||||
Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
|
Vector2 mouse_local_pos = tile_atlas_control->get_local_mouse_position();
|
||||||
@ -1473,7 +1475,7 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
selection.clear();
|
selection.clear();
|
||||||
selection.insert(selected);
|
selection.insert(selected);
|
||||||
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
_update_tile_inspector();
|
_update_tile_inspector();
|
||||||
_update_tile_id_label();
|
_update_tile_id_label();
|
||||||
_update_current_tile_data_editor();
|
_update_current_tile_data_editor();
|
||||||
@ -1503,14 +1505,14 @@ void RTileSetAtlasSourceEditor::_end_dragging() {
|
|||||||
case DRAG_TYPE_RESIZE_LEFT:
|
case DRAG_TYPE_RESIZE_LEFT:
|
||||||
if (drag_start_tile_shape != Rect2i(drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile))) {
|
if (drag_start_tile_shape != Rect2i(drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile))) {
|
||||||
undo_redo->create_action(TTR("Resize a tile"));
|
undo_redo->create_action(TTR("Resize a tile"));
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "move_tile_in_atlas", drag_start_tile_shape.position, drag_current_tile, tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
|
undo_redo->add_do_method(tile_set_atlas_source, "move_tile_in_atlas", Point2(drag_start_tile_shape.position), Vector2(drag_current_tile), tile_set_atlas_source->get_tile_size_in_atlas(drag_current_tile));
|
||||||
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
undo_redo->add_do_method(this, "_set_selection_from_array", _get_selection_as_array());
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "move_tile_in_atlas", drag_current_tile, drag_start_tile_shape.position, drag_start_tile_shape.size);
|
undo_redo->add_undo_method(tile_set_atlas_source, "move_tile_in_atlas", Vector2(drag_current_tile), Vector2(drag_start_tile_shape.position), Vector2(drag_start_tile_shape.size));
|
||||||
Array array;
|
Array array;
|
||||||
array.push_back(drag_start_tile_shape.position);
|
array.push_back(Point2(drag_start_tile_shape.position));
|
||||||
array.push_back(0);
|
array.push_back(0);
|
||||||
undo_redo->add_undo_method(this, "_set_selection_from_array", array);
|
undo_redo->add_undo_method(this, "_set_selection_from_array", array);
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1529,7 +1531,7 @@ Map<Vector2i, List<const PropertyInfo *>> RTileSetAtlasSourceEditor::_group_prop
|
|||||||
Vector<String> components = String(E_property->get().name).split("/", true, 1);
|
Vector<String> components = String(E_property->get().name).split("/", true, 1);
|
||||||
if (components.size() >= 1) {
|
if (components.size() >= 1) {
|
||||||
Vector<String> coord_arr = components[0].split(":");
|
Vector<String> coord_arr = components[0].split(":");
|
||||||
if (coord_arr.size() == 2 && coord_arr[0].is_valid_int() && coord_arr[1].is_valid_int()) {
|
if (coord_arr.size() == 2 && coord_arr[0].is_valid_integer() && coord_arr[1].is_valid_integer()) {
|
||||||
Vector2i coords = Vector2i(coord_arr[0].to_int(), coord_arr[1].to_int());
|
Vector2i coords = Vector2i(coord_arr[0].to_int(), coord_arr[1].to_int());
|
||||||
per_tile[coords].push_back(&(E_property->get()));
|
per_tile[coords].push_back(&(E_property->get()));
|
||||||
}
|
}
|
||||||
@ -1552,8 +1554,8 @@ void RTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
|||||||
TileSelection selected = E->get();
|
TileSelection selected = E->get();
|
||||||
if (selected.alternative == 0) {
|
if (selected.alternative == 0) {
|
||||||
// Remove a tile.
|
// Remove a tile.
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", selected.tile);
|
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", Vector2(selected.tile));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", selected.tile);
|
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", Vector2(selected.tile));
|
||||||
removed.insert(selected.tile);
|
removed.insert(selected.tile);
|
||||||
if (per_tile.has(selected.tile)) {
|
if (per_tile.has(selected.tile)) {
|
||||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
|
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
|
||||||
@ -1572,12 +1574,12 @@ void RTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
|||||||
TileSelection selected = E->get();
|
TileSelection selected = E->get();
|
||||||
if (selected.alternative > 0 && !removed.has(selected.tile)) {
|
if (selected.alternative > 0 && !removed.has(selected.tile)) {
|
||||||
// Remove an alternative tile.
|
// Remove an alternative tile.
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "remove_alternative_tile", selected.tile, selected.alternative);
|
undo_redo->add_do_method(tile_set_atlas_source, "remove_alternative_tile", Vector2(selected.tile), selected.alternative);
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "create_alternative_tile", selected.tile, selected.alternative);
|
undo_redo->add_undo_method(tile_set_atlas_source, "create_alternative_tile", Vector2(selected.tile), selected.alternative);
|
||||||
if (per_tile.has(selected.tile)) {
|
if (per_tile.has(selected.tile)) {
|
||||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
|
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
|
||||||
Vector<String> components = E_property->get()->name.split("/", true, 2);
|
Vector<String> components = E_property->get()->name.split("/", true, 2);
|
||||||
if (components.size() >= 2 && components[1].is_valid_int() && components[1].to_int() == selected.alternative) {
|
if (components.size() >= 2 && components[1].is_valid_integer() && components[1].to_int() == selected.alternative) {
|
||||||
String property = E_property->get()->name;
|
String property = E_property->get()->name;
|
||||||
Variant value = tile_set_atlas_source->get(property);
|
Variant value = tile_set_atlas_source->get(property);
|
||||||
if (value.get_type() != Variant::NIL) {
|
if (value.get_type() != Variant::NIL) {
|
||||||
@ -1594,12 +1596,12 @@ void RTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
|||||||
} break;
|
} break;
|
||||||
case TILE_CREATE: {
|
case TILE_CREATE: {
|
||||||
undo_redo->create_action(TTR("Create a tile"));
|
undo_redo->create_action(TTR("Create a tile"));
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", menu_option_coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", Vector2(menu_option_coords));
|
||||||
Array array;
|
Array array;
|
||||||
array.push_back(menu_option_coords);
|
array.push_back(Vector2(menu_option_coords));
|
||||||
array.push_back(0);
|
array.push_back(0);
|
||||||
undo_redo->add_do_method(this, "_set_selection_from_array", array);
|
undo_redo->add_do_method(this, "_set_selection_from_array", array);
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", menu_option_coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", Vector2(menu_option_coords));
|
||||||
undo_redo->add_undo_method(this, "_set_selection_from_array", _get_selection_as_array());
|
undo_redo->add_undo_method(this, "_set_selection_from_array", _get_selection_as_array());
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
_update_tile_id_label();
|
_update_tile_id_label();
|
||||||
@ -1610,10 +1612,10 @@ void RTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
|||||||
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
if (E->get().alternative == 0) {
|
if (E->get().alternative == 0) {
|
||||||
int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E->get().tile);
|
int next_id = tile_set_atlas_source->get_next_alternative_tile_id(E->get().tile);
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", E->get().tile, next_id);
|
undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", Vector2(E->get().tile), next_id);
|
||||||
array.push_back(E->get().tile);
|
array.push_back(Vector2(E->get().tile));
|
||||||
array.push_back(next_id);
|
array.push_back(next_id);
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", E->get().tile, next_id);
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", Vector2(E->get().tile), next_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
undo_redo->add_do_method(this, "_set_selection_from_array", array);
|
undo_redo->add_do_method(this, "_set_selection_from_array", array);
|
||||||
@ -1644,7 +1646,7 @@ void RTileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
|
|||||||
ERR_FAIL_COND((p_selection.size() % 2) != 0);
|
ERR_FAIL_COND((p_selection.size() % 2) != 0);
|
||||||
selection.clear();
|
selection.clear();
|
||||||
for (int i = 0; i < p_selection.size() / 2; i++) {
|
for (int i = 0; i < p_selection.size() / 2; i++) {
|
||||||
TileSelection selected = { p_selection[i * 2], p_selection[i * 2 + 1] };
|
TileSelection selected = { Vector2(p_selection[i * 2]), Vector2(p_selection[i * 2 + 1]) };
|
||||||
if (tile_set_atlas_source->has_tile(selected.tile) && tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) {
|
if (tile_set_atlas_source->has_tile(selected.tile) && tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) {
|
||||||
selection.insert(selected);
|
selection.insert(selected);
|
||||||
}
|
}
|
||||||
@ -1658,7 +1660,7 @@ void RTileSetAtlasSourceEditor::_set_selection_from_array(Array p_selection) {
|
|||||||
Array RTileSetAtlasSourceEditor::_get_selection_as_array() {
|
Array RTileSetAtlasSourceEditor::_get_selection_as_array() {
|
||||||
Array output;
|
Array output;
|
||||||
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
for (Set<TileSelection>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
output.push_back(E->get().tile);
|
output.push_back(Vector2(E->get().tile));
|
||||||
output.push_back(E->get().alternative);
|
output.push_back(E->get().alternative);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
@ -1827,7 +1829,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileMapCell cell;
|
RTileMapCell cell;
|
||||||
cell.source_id = tile_set_atlas_source_id;
|
cell.source_id = tile_set_atlas_source_id;
|
||||||
cell.set_atlas_coords(coords);
|
cell.set_atlas_coords(coords);
|
||||||
cell.alternative_tile = 0;
|
cell.alternative_tile = 0;
|
||||||
@ -1846,7 +1848,7 @@ void RTileSetAtlasSourceEditor::_tile_atlas_control_unscaled_draw() {
|
|||||||
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
|
Transform2D xform = tile_atlas_control->get_parent_control()->get_transform();
|
||||||
xform.translate(position);
|
xform.translate(position);
|
||||||
|
|
||||||
TileMapCell cell;
|
RTileMapCell cell;
|
||||||
cell.source_id = tile_set_atlas_source_id;
|
cell.source_id = tile_set_atlas_source_id;
|
||||||
cell.set_atlas_coords(E->get().tile);
|
cell.set_atlas_coords(E->get().tile);
|
||||||
cell.alternative_tile = 0;
|
cell.alternative_tile = 0;
|
||||||
@ -1892,11 +1894,11 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<I
|
|||||||
drag_type = DRAG_TYPE_NONE;
|
drag_type = DRAG_TYPE_NONE;
|
||||||
|
|
||||||
Vector2 mouse_local_pos = alternative_tiles_control->get_local_mouse_position();
|
Vector2 mouse_local_pos = alternative_tiles_control->get_local_mouse_position();
|
||||||
if (mb->get_button_index() == MouseButton::LEFT) {
|
if (mb->get_button_index() == BUTTON_LEFT) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
// Left click pressed.
|
// Left click pressed.
|
||||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||||
Vector3 tile = tile_atlas_view->get_alternative_tile_at_pos(mouse_local_pos);
|
Vector3i tile = tile_atlas_view->get_alternative_tile_at_pos(mouse_local_pos);
|
||||||
|
|
||||||
selection.clear();
|
selection.clear();
|
||||||
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
|
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
|
||||||
@ -1908,10 +1910,10 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_gui_input(const Ref<I
|
|||||||
_update_tile_id_label();
|
_update_tile_id_label();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mb->get_button_index() == MouseButton::RIGHT) {
|
} else if (mb->get_button_index() == BUTTON_RIGHT) {
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
// Right click pressed
|
// Right click pressed
|
||||||
Vector3 tile = tile_atlas_view->get_alternative_tile_at_pos(mouse_local_pos);
|
Vector3i tile = tile_atlas_view->get_alternative_tile_at_pos(mouse_local_pos);
|
||||||
|
|
||||||
selection.clear();
|
selection.clear();
|
||||||
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
|
TileSelection selected = { Vector2i(tile.x, tile.y), int(tile.z) };
|
||||||
@ -1994,7 +1996,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileMapCell cell;
|
RTileMapCell cell;
|
||||||
cell.source_id = tile_set_atlas_source_id;
|
cell.source_id = tile_set_atlas_source_id;
|
||||||
cell.set_atlas_coords(coords);
|
cell.set_atlas_coords(coords);
|
||||||
cell.alternative_tile = alternative_tile;
|
cell.alternative_tile = alternative_tile;
|
||||||
@ -2014,7 +2016,7 @@ void RTileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw() {
|
|||||||
Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
|
Transform2D xform = alternative_tiles_control->get_parent_control()->get_transform();
|
||||||
xform.translate(position);
|
xform.translate(position);
|
||||||
|
|
||||||
TileMapCell cell;
|
RTileMapCell cell;
|
||||||
cell.source_id = tile_set_atlas_source_id;
|
cell.source_id = tile_set_atlas_source_id;
|
||||||
cell.set_atlas_coords(E->get().tile);
|
cell.set_atlas_coords(E->get().tile);
|
||||||
cell.alternative_tile = E->get().alternative;
|
cell.alternative_tile = E->get().alternative;
|
||||||
@ -2095,7 +2097,7 @@ void RTileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_red
|
|||||||
arr = atlas_source->get_tiles_to_be_removed_on_change(atlas_source->get_texture(), atlas_source->get_margins(), atlas_source->get_separation(), p_new_value);
|
arr = atlas_source->get_tiles_to_be_removed_on_change(atlas_source->get_texture(), atlas_source->get_margins(), atlas_source->get_separation(), p_new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arr.is_empty()) {
|
if (!arr.empty()) {
|
||||||
// Get all properties assigned to a tile.
|
// Get all properties assigned to a tile.
|
||||||
List<PropertyInfo> properties;
|
List<PropertyInfo> properties;
|
||||||
atlas_source->get_property_list(&properties);
|
atlas_source->get_property_list(&properties);
|
||||||
@ -2195,8 +2197,8 @@ void RTileSetAtlasSourceEditor::_auto_create_tiles() {
|
|||||||
|
|
||||||
// If we do have opaque pixels, create a tile.
|
// If we do have opaque pixels, create a tile.
|
||||||
if (is_opaque) {
|
if (is_opaque) {
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "create_tile", Vector2(coords));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "remove_tile", Vector2(coords));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2249,8 +2251,8 @@ void RTileSetAtlasSourceEditor::_auto_remove_tiles() {
|
|||||||
|
|
||||||
// If we do have opaque pixels, create a tile.
|
// If we do have opaque pixels, create a tile.
|
||||||
if (!is_opaque) {
|
if (!is_opaque) {
|
||||||
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", coords);
|
undo_redo->add_do_method(tile_set_atlas_source, "remove_tile", Vector2(coords));
|
||||||
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", coords);
|
undo_redo->add_undo_method(tile_set_atlas_source, "create_tile", Vector2(coords));
|
||||||
if (per_tile.has(coords)) {
|
if (per_tile.has(coords)) {
|
||||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
for (List<const PropertyInfo *>::Element *E_property = per_tile[coords].front(); E_property; E_property = E_property->next()) {
|
||||||
String property = E_property->get()->name;
|
String property = E_property->get()->name;
|
||||||
@ -2270,16 +2272,16 @@ void RTileSetAtlasSourceEditor::_notification(int p_what) {
|
|||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE:
|
case NOTIFICATION_ENTER_TREE:
|
||||||
case NOTIFICATION_THEME_CHANGED:
|
case NOTIFICATION_THEME_CHANGED:
|
||||||
tool_setup_atlas_source_button->set_icon(get_theme_icon(("Tools"), ("EditorIcons")));
|
tool_setup_atlas_source_button->set_icon(get_icon(("Tools"), ("EditorIcons")));
|
||||||
tool_select_button->set_icon(get_theme_icon(("ToolSelect"), ("EditorIcons")));
|
tool_select_button->set_icon(get_icon(("ToolSelect"), ("EditorIcons")));
|
||||||
tool_paint_button->set_icon(get_theme_icon(("CanvasItem"), ("EditorIcons")));
|
tool_paint_button->set_icon(get_icon(("CanvasItem"), ("EditorIcons")));
|
||||||
|
|
||||||
tools_settings_erase_button->set_icon(get_theme_icon(("Eraser"), ("EditorIcons")));
|
tools_settings_erase_button->set_icon(get_icon(("Eraser"), ("EditorIcons")));
|
||||||
|
|
||||||
tool_advanced_menu_buttom->set_icon(get_theme_icon(("GuiTabMenuHl"), ("EditorIcons")));
|
tool_advanced_menu_buttom->set_icon(get_icon(("GuiTabMenuHl"), ("EditorIcons")));
|
||||||
|
|
||||||
resize_handle = get_theme_icon(("EditorHandle"), ("EditorIcons"));
|
resize_handle = get_icon(("EditorHandle"), ("EditorIcons"));
|
||||||
resize_handle_disabled = get_theme_icon(("EditorHandleDisabled"), ("EditorIcons"));
|
resize_handle_disabled = get_icon(("EditorHandleDisabled"), ("EditorIcons"));
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_INTERNAL_PROCESS:
|
case NOTIFICATION_INTERNAL_PROCESS:
|
||||||
if (tile_set_changed_needs_update) {
|
if (tile_set_changed_needs_update) {
|
||||||
@ -2399,8 +2401,8 @@ RTileSetAtlasSourceEditor::RTileSetAtlasSourceEditor() {
|
|||||||
confirm_auto_create_tiles = memnew(AcceptDialog);
|
confirm_auto_create_tiles = memnew(AcceptDialog);
|
||||||
confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?"));
|
confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?"));
|
||||||
confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?"));
|
confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?"));
|
||||||
confirm_auto_create_tiles->get_ok_button()->set_text(TTR("Yes"));
|
confirm_auto_create_tiles->get_ok()->set_text(TTR("Yes"));
|
||||||
confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No"));
|
confirm_auto_create_tiles->add_cancel()->set_text(TTR("No"));
|
||||||
confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &RTileSetAtlasSourceEditor::_auto_create_tiles));
|
confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &RTileSetAtlasSourceEditor::_auto_create_tiles));
|
||||||
add_child(confirm_auto_create_tiles);
|
add_child(confirm_auto_create_tiles);
|
||||||
|
|
||||||
@ -2560,13 +2562,13 @@ void REditorPropertyTilePolygon::_add_focusable_children(Node *p_node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void REditorPropertyTilePolygon::_polygons_changed() {
|
void REditorPropertyTilePolygon::_polygons_changed() {
|
||||||
if (String(count_property).is_empty()) {
|
if (String(count_property).empty()) {
|
||||||
if (base_type == "OccluderPolygon2D") {
|
if (base_type == "OccluderPolygon2D") {
|
||||||
// Single OccluderPolygon2D.
|
// Single OccluderPolygon2D.
|
||||||
Ref<OccluderPolygon2D> occluder;
|
Ref<OccluderPolygon2D> occluder;
|
||||||
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
||||||
occluder.instance();
|
occluder.instance();
|
||||||
occluder->set_polygon(generic_tile_polygon_editor->get_polygon(0));
|
occluder->set_polygon(generic_tile_polygon_editor->get_polygon_poolvector(0));
|
||||||
}
|
}
|
||||||
emit_changed(get_edited_property(), occluder);
|
emit_changed(get_edited_property(), occluder);
|
||||||
} else if (base_type == "NavigationPolygon") {
|
} else if (base_type == "NavigationPolygon") {
|
||||||
@ -2574,7 +2576,7 @@ void REditorPropertyTilePolygon::_polygons_changed() {
|
|||||||
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
||||||
navigation_polygon.instance();
|
navigation_polygon.instance();
|
||||||
for (int i = 0; i < generic_tile_polygon_editor->get_polygon_count(); i++) {
|
for (int i = 0; i < generic_tile_polygon_editor->get_polygon_count(); i++) {
|
||||||
Vector<Vector2> polygon = generic_tile_polygon_editor->get_polygon(i);
|
PoolVector2Array polygon = generic_tile_polygon_editor->get_polygon_poolvector(i);
|
||||||
navigation_polygon->add_outline(polygon);
|
navigation_polygon->add_outline(polygon);
|
||||||
}
|
}
|
||||||
navigation_polygon->make_polygons_from_outlines();
|
navigation_polygon->make_polygons_from_outlines();
|
||||||
@ -2582,7 +2584,7 @@ void REditorPropertyTilePolygon::_polygons_changed() {
|
|||||||
emit_changed(get_edited_property(), navigation_polygon);
|
emit_changed(get_edited_property(), navigation_polygon);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (base_type.is_empty()) {
|
if (base_type.empty()) {
|
||||||
// Multiple array of vertices.
|
// Multiple array of vertices.
|
||||||
Vector<String> changed_properties;
|
Vector<String> changed_properties;
|
||||||
Array values;
|
Array values;
|
||||||
@ -2601,7 +2603,7 @@ void REditorPropertyTilePolygon::_polygons_changed() {
|
|||||||
void REditorPropertyTilePolygon::update_property() {
|
void REditorPropertyTilePolygon::update_property() {
|
||||||
RTileSetAtlasSourceEditor::AtlasTileProxyObject *atlas_tile_proxy_object = Object::cast_to<RTileSetAtlasSourceEditor::AtlasTileProxyObject>(get_edited_object());
|
RTileSetAtlasSourceEditor::AtlasTileProxyObject *atlas_tile_proxy_object = Object::cast_to<RTileSetAtlasSourceEditor::AtlasTileProxyObject>(get_edited_object());
|
||||||
ERR_FAIL_COND(!atlas_tile_proxy_object);
|
ERR_FAIL_COND(!atlas_tile_proxy_object);
|
||||||
ERR_FAIL_COND(atlas_tile_proxy_object->get_edited_tiles().is_empty());
|
ERR_FAIL_COND(atlas_tile_proxy_object->get_edited_tiles().empty());
|
||||||
|
|
||||||
RTileSetAtlasSource *tile_set_atlas_source = atlas_tile_proxy_object->get_edited_tile_set_atlas_source();
|
RTileSetAtlasSource *tile_set_atlas_source = atlas_tile_proxy_object->get_edited_tile_set_atlas_source();
|
||||||
generic_tile_polygon_editor->set_tile_set(Ref<RTileSet>(tile_set_atlas_source->get_tile_set()));
|
generic_tile_polygon_editor->set_tile_set(Ref<RTileSet>(tile_set_atlas_source->get_tile_set()));
|
||||||
@ -2609,19 +2611,19 @@ void REditorPropertyTilePolygon::update_property() {
|
|||||||
// Set the background
|
// Set the background
|
||||||
Vector2i coords = atlas_tile_proxy_object->get_edited_tiles().front()->get().tile;
|
Vector2i coords = atlas_tile_proxy_object->get_edited_tiles().front()->get().tile;
|
||||||
int alternative = atlas_tile_proxy_object->get_edited_tiles().front()->get().alternative;
|
int alternative = atlas_tile_proxy_object->get_edited_tiles().front()->get().alternative;
|
||||||
TileData *tile_data = Object::cast_to<TileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
RTileData *tile_data = Object::cast_to<RTileData>(tile_set_atlas_source->get_tile_data(coords, alternative));
|
||||||
generic_tile_polygon_editor->set_background(tile_set_atlas_source->get_texture(), tile_set_atlas_source->get_tile_texture_region(coords), tile_set_atlas_source->get_tile_effective_texture_offset(coords, alternative), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
|
generic_tile_polygon_editor->set_background(tile_set_atlas_source->get_texture(), tile_set_atlas_source->get_tile_texture_region(coords), tile_set_atlas_source->get_tile_effective_texture_offset(coords, alternative), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate());
|
||||||
|
|
||||||
// Reset the polygons.
|
// Reset the polygons.
|
||||||
generic_tile_polygon_editor->clear_polygons();
|
generic_tile_polygon_editor->clear_polygons();
|
||||||
|
|
||||||
if (String(count_property).is_empty()) {
|
if (String(count_property).empty()) {
|
||||||
if (base_type == "OccluderPolygon2D") {
|
if (base_type == "OccluderPolygon2D") {
|
||||||
// Single OccluderPolygon2D.
|
// Single OccluderPolygon2D.
|
||||||
Ref<OccluderPolygon2D> occluder = get_edited_object()->get(get_edited_property());
|
Ref<OccluderPolygon2D> occluder = get_edited_object()->get(get_edited_property());
|
||||||
generic_tile_polygon_editor->clear_polygons();
|
generic_tile_polygon_editor->clear_polygons();
|
||||||
if (occluder.is_valid()) {
|
if (occluder.is_valid()) {
|
||||||
generic_tile_polygon_editor->add_polygon(occluder->get_polygon());
|
generic_tile_polygon_editor->add_polygon_poolvector(occluder->get_polygon());
|
||||||
}
|
}
|
||||||
} else if (base_type == "NavigationPolygon") {
|
} else if (base_type == "NavigationPolygon") {
|
||||||
// Single OccluderPolygon2D.
|
// Single OccluderPolygon2D.
|
||||||
@ -2629,13 +2631,13 @@ void REditorPropertyTilePolygon::update_property() {
|
|||||||
generic_tile_polygon_editor->clear_polygons();
|
generic_tile_polygon_editor->clear_polygons();
|
||||||
if (navigation_polygon.is_valid()) {
|
if (navigation_polygon.is_valid()) {
|
||||||
for (int i = 0; i < navigation_polygon->get_outline_count(); i++) {
|
for (int i = 0; i < navigation_polygon->get_outline_count(); i++) {
|
||||||
generic_tile_polygon_editor->add_polygon(navigation_polygon->get_outline(i));
|
generic_tile_polygon_editor->add_polygon_poolvector(navigation_polygon->get_outline(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int count = get_edited_object()->get(count_property);
|
int count = get_edited_object()->get(count_property);
|
||||||
if (base_type.is_empty()) {
|
if (base_type.empty()) {
|
||||||
// Multiple array of vertices.
|
// Multiple array of vertices.
|
||||||
generic_tile_polygon_editor->clear_polygons();
|
generic_tile_polygon_editor->clear_polygons();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user