mirror of
https://github.com/Relintai/pandemonium_engine_minimal.git
synced 2024-11-17 22:17:19 +01:00
Don't include DynamicFont directly in SceneTree.
This commit is contained in:
parent
3aeb11b230
commit
af77693b6c
@ -28,7 +28,6 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include "dynamic_font.h"
|
||||
|
||||
#include "core/os/file_access.h"
|
||||
@ -1460,3 +1459,12 @@ String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path)
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void ResourceFormatLoaderDynamicFont::_scene_tree_update_font_oversampling(float p_ratio) {
|
||||
DynamicFontAtSize::font_oversampling = p_ratio;
|
||||
DynamicFont::update_oversampling();
|
||||
}
|
||||
|
||||
void ResourceFormatLoaderDynamicFont::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_scene_tree_update_font_oversampling"), &ResourceFormatLoaderDynamicFont::_scene_tree_update_font_oversampling);
|
||||
}
|
@ -30,10 +30,10 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/containers/pair.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "core/containers/pair.h"
|
||||
#include "scene/resources/font/font.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
@ -387,11 +387,18 @@ VARIANT_ENUM_CAST(DynamicFont::SpacingType);
|
||||
/////////////
|
||||
|
||||
class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
|
||||
GDCLASS(ResourceFormatLoaderDynamicFont, ResourceFormatLoader);
|
||||
|
||||
public:
|
||||
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_no_subresource_cache = false);
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
virtual bool handles_type(const String &p_type) const;
|
||||
virtual String get_resource_type(const String &p_path) const;
|
||||
|
||||
void _scene_tree_update_font_oversampling(float p_ratio);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif // DYNAMIC_FONT_H
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "register_types.h"
|
||||
|
||||
#include "dynamic_font.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
|
||||
static Ref<ResourceFormatLoaderDynamicFont> resource_loader_dynamic_font;
|
||||
|
||||
@ -46,6 +47,12 @@ void register_freetype_types(ModuleRegistrationLevel p_level) {
|
||||
|
||||
DynamicFont::initialize_dynamic_fonts();
|
||||
}
|
||||
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_FINALIZE) {
|
||||
if (SceneTree::get_singleton()) {
|
||||
SceneTree::get_singleton()->connect("update_font_oversampling_request", resource_loader_dynamic_font.ptr(), "_scene_tree_update_font_oversampling");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unregister_freetype_types(ModuleRegistrationLevel p_level) {
|
||||
|
@ -55,12 +55,6 @@
|
||||
#include "servers/physics_2d_server.h"
|
||||
#include "viewport.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For freetype.
|
||||
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
#include "modules/freetype/dynamic_font.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -597,12 +591,9 @@ void SceneTree::iteration_end() {
|
||||
}
|
||||
|
||||
void SceneTree::_update_font_oversampling(float p_ratio) {
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
if (use_font_oversampling) {
|
||||
DynamicFontAtSize::font_oversampling = p_ratio;
|
||||
DynamicFont::update_oversampling();
|
||||
emit_signal("update_font_oversampling_request", p_ratio);
|
||||
}
|
||||
#endif // MODULE_FREETYPE_ENABLED
|
||||
}
|
||||
|
||||
bool SceneTree::idle(float p_time) {
|
||||
@ -1860,6 +1851,7 @@ void SceneTree::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("connected_to_server"));
|
||||
ADD_SIGNAL(MethodInfo("connection_failed"));
|
||||
ADD_SIGNAL(MethodInfo("server_disconnected"));
|
||||
ADD_SIGNAL(MethodInfo("update_font_oversampling_request", PropertyInfo(Variant::REAL, "ratio")));
|
||||
|
||||
BIND_ENUM_CONSTANT(GROUP_CALL_DEFAULT);
|
||||
BIND_ENUM_CONSTANT(GROUP_CALL_REVERSE);
|
||||
|
Loading…
Reference in New Issue
Block a user