Work on fixing compile when layered tile maps are enabled.

This commit is contained in:
Relintai 2024-03-06 01:11:54 +01:00
parent 4abb1a23e9
commit ea110ae724
8 changed files with 384 additions and 307 deletions

View File

@ -50,7 +50,7 @@
</description> </description>
</method> </method>
<method name="get_runtime_texture" qualifiers="const"> <method name="get_runtime_texture" qualifiers="const">
<return type="Texture2D" /> <return type="Texture" />
<description> <description>
If [member use_texture_padding] is [code]false[/code], returns [member texture]. Otherwise, returns and internal [ImageTexture] created that includes the padding. If [member use_texture_padding] is [code]false[/code], returns [member texture]. Otherwise, returns and internal [ImageTexture] created that includes the padding.
</description> </description>
@ -146,7 +146,7 @@
</method> </method>
<method name="get_tiles_to_be_removed_on_change"> <method name="get_tiles_to_be_removed_on_change">
<return type="PoolVector2Array" /> <return type="PoolVector2Array" />
<param index="0" name="texture" type="Texture2D" /> <param index="0" name="texture" type="Texture" />
<param index="1" name="margins" type="Vector2i" /> <param index="1" name="margins" type="Vector2i" />
<param index="2" name="separation" type="Vector2i" /> <param index="2" name="separation" type="Vector2i" />
<param index="3" name="texture_region_size" type="Vector2i" /> <param index="3" name="texture_region_size" type="Vector2i" />
@ -266,7 +266,7 @@
<member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)"> <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)">
Separation, in pixels, between each tile texture region of the grid. Separation, in pixels, between each tile texture region of the grid.
</member> </member>
<member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> <member name="texture" type="Texture" setter="set_texture" getter="get_texture">
The atlas texture. The atlas texture.
</member> </member>
<member name="texture_region_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)"> <member name="texture_region_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)">

View File

@ -200,7 +200,7 @@ void AtlasMergingDialog::_merge_confirmed(const String &p_path) {
ResourceLoader::import(p_path); ResourceLoader::import(p_path);
Ref<Texture> new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); Ref<Texture> new_texture_resource = ResourceLoader::load(p_path, "Texture");
merged->set_texture(new_texture_resource); merged->set_texture(new_texture_resource);
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();

View File

@ -119,7 +119,9 @@ private:
void _update_toolbar(); void _update_toolbar();
void _update_transform_buttons(); void _update_transform_buttons();
void _set_transform_buttons_state(const Vector<Button *> &p_enabled_buttons, const Vector<Button *> &p_disabled_buttons, const String &p_why_disabled);
void _set_transform_button_state_enabled(Button *p_button);
void _set_transform_button_state_disabled(Button *p_button, const String &p_why_disabled);
///// Tilemap editing. ///// ///// Tilemap editing. /////
bool has_mouse = false; bool has_mouse = false;

View File

@ -114,7 +114,7 @@ void LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceProxyObject::_get
p_list->push_back(PropertyInfo(Variant::NIL, TTR("Atlas"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); p_list->push_back(PropertyInfo(Variant::NIL, TTR("Atlas"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY));
p_list->push_back(PropertyInfo(Variant::INT, PNAME("id"), PROPERTY_HINT_RANGE, "0," + itos(INT_MAX) + ",1")); p_list->push_back(PropertyInfo(Variant::INT, PNAME("id"), PROPERTY_HINT_RANGE, "0," + itos(INT_MAX) + ",1"));
p_list->push_back(PropertyInfo(Variant::STRING, PNAME("name"))); p_list->push_back(PropertyInfo(Variant::STRING, PNAME("name")));
p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("texture"), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("texture"), PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("margins"), PROPERTY_HINT_NONE, "suffix:px")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("margins"), PROPERTY_HINT_NONE, "suffix:px"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("separation"), PROPERTY_HINT_NONE, "suffix:px")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("separation"), PROPERTY_HINT_NONE, "suffix:px"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("texture_region_size"), PROPERTY_HINT_NONE, "suffix:px")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("texture_region_size"), PROPERTY_HINT_NONE, "suffix:px"));

View File

@ -90,7 +90,7 @@ bool LayeredTileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Varian
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
String ftype = EditorFileSystem::get_singleton()->get_file_type(files[i]); String ftype = EditorFileSystem::get_singleton()->get_file_type(files[i]);
if (!ClassDB::is_parent_class(ftype, "Texture2D")) { if (!ClassDB::is_parent_class(ftype, "Texture")) {
return false; return false;
} }
} }
@ -304,7 +304,7 @@ void LayeredTileSetEditor::_source_add_id_pressed(int p_id_pressed) {
texture_file_dialog->connect("files_selected", callable_mp(this, &LayeredTileSetEditor::_load_texture_files)); texture_file_dialog->connect("files_selected", callable_mp(this, &LayeredTileSetEditor::_load_texture_files));
List<String> extensions; List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
for (const String &E : extensions) { for (const String &E : extensions) {
texture_file_dialog->add_filter("*." + E, E.to_upper()); texture_file_dialog->add_filter("*." + E, E.to_upper());
} }

View File

@ -4715,6 +4715,13 @@ Ref<Texture> LayeredTileSetAtlasSource::get_texture() const {
return texture; return texture;
} }
void LayeredTileSetAtlasSource::set_normal_texture(Ref<Texture> p_texture) {
normal_texture = p_texture;
}
Ref<Texture> LayeredTileSetAtlasSource::get_normal_texture() const {
return normal_texture;
}
void LayeredTileSetAtlasSource::set_margins(Vector2i p_margins) { void LayeredTileSetAtlasSource::set_margins(Vector2i p_margins) {
if (p_margins.x < 0 || p_margins.y < 0) { if (p_margins.x < 0 || p_margins.y < 0) {
WARN_PRINT("Atlas source margins should be positive."); WARN_PRINT("Atlas source margins should be positive.");
@ -5526,6 +5533,10 @@ LayeredTileData *LayeredTileSetAtlasSource::get_tile_data(const Vector2i p_atlas
void LayeredTileSetAtlasSource::_bind_methods() { void LayeredTileSetAtlasSource::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &LayeredTileSetAtlasSource::set_texture); ClassDB::bind_method(D_METHOD("set_texture", "texture"), &LayeredTileSetAtlasSource::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &LayeredTileSetAtlasSource::get_texture); ClassDB::bind_method(D_METHOD("get_texture"), &LayeredTileSetAtlasSource::get_texture);
ClassDB::bind_method(D_METHOD("set_normal_texture", "texture"), &LayeredTileSetAtlasSource::set_normal_texture);
ClassDB::bind_method(D_METHOD("get_normal_texture"), &LayeredTileSetAtlasSource::get_normal_texture);
ClassDB::bind_method(D_METHOD("set_margins", "margins"), &LayeredTileSetAtlasSource::set_margins); ClassDB::bind_method(D_METHOD("set_margins", "margins"), &LayeredTileSetAtlasSource::set_margins);
ClassDB::bind_method(D_METHOD("get_margins"), &LayeredTileSetAtlasSource::get_margins); ClassDB::bind_method(D_METHOD("get_margins"), &LayeredTileSetAtlasSource::get_margins);
ClassDB::bind_method(D_METHOD("set_separation", "separation"), &LayeredTileSetAtlasSource::set_separation); ClassDB::bind_method(D_METHOD("set_separation", "separation"), &LayeredTileSetAtlasSource::set_separation);
@ -5535,7 +5546,8 @@ void LayeredTileSetAtlasSource::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_texture_padding", "use_texture_padding"), &LayeredTileSetAtlasSource::set_use_texture_padding); ClassDB::bind_method(D_METHOD("set_use_texture_padding", "use_texture_padding"), &LayeredTileSetAtlasSource::set_use_texture_padding);
ClassDB::bind_method(D_METHOD("get_use_texture_padding"), &LayeredTileSetAtlasSource::get_use_texture_padding); ClassDB::bind_method(D_METHOD("get_use_texture_padding"), &LayeredTileSetAtlasSource::get_use_texture_padding);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR), "set_normal_texture", "get_normal_texture");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_margins", "get_margins"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_margins", "get_margins");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_separation", "get_separation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "separation", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_separation", "get_separation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "texture_region_size", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_texture_region_size", "get_texture_region_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "texture_region_size", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NOEDITOR), "set_texture_region_size", "get_texture_region_size");

View File

@ -698,6 +698,10 @@ public:
// Base properties. // Base properties.
void set_texture(Ref<Texture> p_texture); void set_texture(Ref<Texture> p_texture);
Ref<Texture> get_texture() const; Ref<Texture> get_texture() const;
void set_normal_texture(Ref<Texture> p_texture);
Ref<Texture> get_normal_texture() const;
void set_margins(Vector2i p_margins); void set_margins(Vector2i p_margins);
Vector2i get_margins() const; Vector2i get_margins() const;
void set_separation(Vector2i p_separation); void set_separation(Vector2i p_separation);