summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/control.h4
-rw-r--r--scene/gui/scroll_container.cpp4
-rw-r--r--scene/register_scene_types.cpp8
-rw-r--r--scene/resources/font.cpp39
-rw-r--r--scene/resources/font.h8
5 files changed, 59 insertions, 4 deletions
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 2d61ecb2af..51325f27b5 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -317,11 +317,11 @@ public:
/* POSITIONING */
- void set_anchors_preset(LayoutPreset p_preset, bool p_keep_margin = false);
+ void set_anchors_preset(LayoutPreset p_preset, bool p_keep_margin = true);
void set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
void set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
- void set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin = false, bool p_push_opposite_anchor = true);
+ void set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin = true, bool p_push_opposite_anchor = true);
float get_anchor(Margin p_margin) const;
void set_margin(Margin p_margin, float p_value);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 413edca218..33b3d46486 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -462,9 +462,9 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position);
- ClassDB::bind_method(D_METHOD("set_h_scroll", "val"), &ScrollContainer::set_h_scroll);
+ ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &ScrollContainer::set_h_scroll);
ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll);
- ClassDB::bind_method(D_METHOD("set_v_scroll", "val"), &ScrollContainer::set_v_scroll);
+ ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll);
ClassDB::bind_method(D_METHOD("get_v_scroll"), &ScrollContainer::get_v_scroll);
ADD_GROUP("Scroll", "scroll_");
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 2dee74f561..bb0cf168af 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -201,6 +201,8 @@ static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL;
+static ResourceFormatLoaderBMFont *resource_loader_bmfont = NULL;
+
static ResourceFormatSaverShader *resource_saver_shader = NULL;
static ResourceFormatLoaderShader *resource_loader_shader = NULL;
@@ -233,6 +235,9 @@ void register_scene_types() {
resource_loader_shader = memnew(ResourceFormatLoaderShader);
ResourceLoader::add_resource_format_loader(resource_loader_shader, true);
+ resource_loader_bmfont = memnew(ResourceFormatLoaderBMFont);
+ ResourceLoader::add_resource_format_loader(resource_loader_bmfont, true);
+
OS::get_singleton()->yield(); //may take time to init
ClassDB::register_class<Object>();
@@ -652,6 +657,9 @@ void unregister_scene_types() {
if (resource_loader_shader) {
memdelete(resource_loader_shader);
}
+ if (resource_loader_bmfont) {
+ memdelete(resource_loader_bmfont);
+ }
SpatialMaterial::finish_shaders();
ParticlesMaterial::finish_shaders();
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 026bcea270..6fc5778dd8 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -596,3 +596,42 @@ BitmapFont::~BitmapFont() {
clear();
}
+
+////////////
+
+RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
+
+ if (r_error)
+ *r_error = ERR_FILE_CANT_OPEN;
+
+ Ref<BitmapFont> font;
+ font.instance();
+
+ Error err = font->create_from_fnt(p_path);
+
+ if (err) {
+ if (r_error)
+ *r_error = err;
+ return RES();
+ }
+
+ return font;
+}
+
+void ResourceFormatLoaderBMFont::get_recognized_extensions(List<String> *p_extensions) const {
+
+ p_extensions->push_back("fnt");
+}
+
+bool ResourceFormatLoaderBMFont::handles_type(const String &p_type) const {
+
+ return (p_type == "BitmapFont");
+}
+
+String ResourceFormatLoaderBMFont::get_resource_type(const String &p_path) const {
+
+ String el = p_path.get_extension().to_lower();
+ if (el == "fnt")
+ return "BitmapFont";
+ return "";
+}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 3f228ca002..ae08890be3 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -159,4 +159,12 @@ public:
~BitmapFont();
};
+class ResourceFormatLoaderBMFont : public ResourceFormatLoader {
+public:
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ 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;
+};
+
#endif