Added default_pixels_per_unit property to the Prop2DCache singleton.

This commit is contained in:
Relintai 2022-02-23 09:36:45 +01:00
parent 5e12fc6525
commit 37b2ab5b5e
2 changed files with 18 additions and 0 deletions

View File

@ -72,6 +72,13 @@ Prop2DCache *Prop2DCache::get_singleton() {
return _instance;
}
float Prop2DCache::get_default_pixels_per_unit() const {
return _default_pixels_per_unit;
}
void Prop2DCache::set_default_pixels_per_unit(const float value) {
_default_pixels_per_unit = value;
}
StringName Prop2DCache::get_default_prop_material_cache_class() {
return _default_prop_material_cache_class;
}
@ -332,6 +339,8 @@ Ref<Resource> Prop2DCache::load_resource(const String &path, const String &type_
Prop2DCache::Prop2DCache() {
_instance = this;
_default_pixels_per_unit = GLOBAL_DEF("props_2d/default_pixels_per_unit", 64);
#if TEXTURE_PACKER_PRESENT
_default_prop_material_cache_class = GLOBAL_DEF("props_2d/default_prop_material_cache_class", "Prop2DMaterialCachePCM");
#else
@ -359,6 +368,10 @@ Prop2DCache::~Prop2DCache() {
}
void Prop2DCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_pixels_per_unit"), &Prop2DCache::get_default_pixels_per_unit);
ClassDB::bind_method(D_METHOD("set_default_pixels_per_unit", "value"), &Prop2DCache::set_default_pixels_per_unit);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "default_pixels_per_unit"), "set_default_pixels_per_unit", "get_default_pixels_per_unit");
ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &Prop2DCache::get_default_prop_material_cache_class);
ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &Prop2DCache::set_default_prop_material_cache_class);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "default_prop_material_cache_class"), "set_default_prop_material_cache_class", "get_default_prop_material_cache_class");

View File

@ -56,6 +56,9 @@ class Prop2DCache : public Object {
public:
static Prop2DCache *get_singleton();
float get_default_pixels_per_unit() const;
void set_default_pixels_per_unit(const float value);
StringName get_default_prop_material_cache_class();
void set_default_prop_material_cache_class(const StringName &cls_name);
@ -105,6 +108,8 @@ public:
protected:
static void _bind_methods();
float _default_pixels_per_unit;
StringName _default_prop_material_cache_class;
Map<uint64_t, Ref<Prop2DMaterialCache>> _material_cache;