diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/line_builder.cpp | 2 | ||||
-rw-r--r-- | scene/gui/box_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/control.cpp | 2 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 2 | ||||
-rw-r--r-- | scene/gui/scroll_bar.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 | ||||
-rw-r--r-- | scene/io/resource_format_wav.cpp | 2 | ||||
-rw-r--r-- | scene/main/scene_main_loop.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | scene/main/timer.cpp | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | scene/main/timer.h | 9 | ||||
-rw-r--r-- | scene/resources/audio_stream_sample.cpp | 2 | ||||
-rw-r--r-- | scene/resources/curve.h | 6 | ||||
-rwxr-xr-x | scene/resources/default_theme/make_header.py | 2 | ||||
-rw-r--r-- | scene/resources/dynamic_font.cpp | 26 | ||||
-rw-r--r-- | scene/resources/dynamic_font.h | 1 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 2 | ||||
-rw-r--r-- | scene/resources/shader.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 2 |
19 files changed, 65 insertions, 31 deletions
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 0912f6cfe8..024c0b89ee 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -515,7 +515,7 @@ void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation o void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect) { // Make a standalone arc that doesn't use existing vertices, - // with undistorted UVs from withing a square section + // with undistorted UVs from within a square section float radius = vbegin.length(); float angle_step = Math_PI / static_cast<float>(round_precision); diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 7c1487c42f..1096c43c10 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -98,7 +98,7 @@ void BoxContainer::_resort() { elements exist */ bool has_stretched = false; - while (stretch_ratio_total > 0) { // first of all, dont even be here if no stretchable objects exist + while (stretch_ratio_total > 0) { // first of all, don't even be here if no stretchable objects exist has_stretched = true; bool refit_successful = true; //assume refit-test will go well diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a8e364a4cd..d2f3eea721 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -485,7 +485,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_MOVED_IN_PARENT: { // some parents need to know the order of the childrens to draw (like TabContainer) - // update if necesary + // update if necessary if (data.parent) data.parent->update(); update(); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index a58e62f061..35d54d9843 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -42,7 +42,7 @@ void WindowDialog::_post_popup() { void WindowDialog::_fix_size() { - // Perhaps this should be called when the viewport resizes aswell or windows go out of bounds... + // Perhaps this should be called when the viewport resizes as well or windows go out of bounds... // Ensure the whole window is visible. Point2i pos = get_global_pos(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 322d9dee20..eaa2a66a56 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -125,7 +125,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int if (cfont.is_null()) cfont = p_base_font; - //line height should be the font height for the first time, this ensures that an empty line will never have zero height and succesive newlines are displayed + //line height should be the font height for the first time, this ensures that an empty line will never have zero height and successive newlines are displayed int line_height = cfont->get_height(); Variant meta; diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 37f7b46e22..b27104f788 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -705,7 +705,7 @@ void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b.but if (value_ofs>(get_max()-get_page())) value_ofs=get_max()-get_page(); if (get_val()==value_ofs) - return; //dont bother if the value is the same + return; //don't bother if the value is the same set_val( value_ofs ); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index d63ef41239..9a999c9323 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2912,7 +2912,7 @@ int Tree::get_column_width(int p_column) const { if (expand_area < expanding_total) return columns[p_column].min_width; - ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldnt happen + ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldn't happen return expand_area * columns[p_column].min_width / expanding_total; } diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp index 1e14d01f4e..0d64743d1e 100644 --- a/scene/io/resource_format_wav.cpp +++ b/scene/io/resource_format_wav.cpp @@ -136,7 +136,7 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original break; } - /* Dont need anything else, continue */ + /* Don't need anything else, continue */ format_found=true; } diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index e766d1c149..79ee4a6f75 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -573,7 +573,7 @@ bool SceneTree::idle(float p_time) { } _flush_ugc(); - _flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications + _flush_transform_notifications(); //transforms after world update, to avoid unnecessary enter/exit notifications call_group_flags(GROUP_CALL_REALTIME, "_viewports", "update_worlds"); root_lock--; diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 5df30e5080..2263e82312 100644..100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -116,16 +116,20 @@ void Timer::stop() { autostart = false; } -void Timer::set_active(bool p_active) { - if (active == p_active) +void Timer::set_paused(bool p_paused) { + if (paused == p_paused) return; - active = p_active; + paused = p_paused; _set_process(processing); } -bool Timer::is_active() const { - return active; +bool Timer::is_paused() const { + return paused; +} + +bool Timer::is_stopped() const { + return get_time_left() <= 0; } float Timer::get_time_left() const { @@ -162,8 +166,8 @@ Timer::TimerProcessMode Timer::get_timer_process_mode() const { void Timer::_set_process(bool p_process, bool p_force) { switch (timer_process_mode) { - case TIMER_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break; - case TIMER_PROCESS_IDLE: set_process_internal(p_process && active); break; + case TIMER_PROCESS_FIXED: set_fixed_process_internal(p_process && !paused); break; + case TIMER_PROCESS_IDLE: set_process_internal(p_process && !paused); break; } processing = p_process; } @@ -182,8 +186,10 @@ void Timer::_bind_methods() { ClassDB::bind_method(D_METHOD("start"), &Timer::start); ClassDB::bind_method(D_METHOD("stop"), &Timer::stop); - ClassDB::bind_method(D_METHOD("set_active", "active"), &Timer::set_active); - ClassDB::bind_method(D_METHOD("is_active"), &Timer::is_active); + ClassDB::bind_method(D_METHOD("set_paused", "paused"), &Timer::set_paused); + ClassDB::bind_method(D_METHOD("is_paused"), &Timer::is_paused); + + ClassDB::bind_method(D_METHOD("is_stopped"), &Timer::is_stopped); ClassDB::bind_method(D_METHOD("get_time_left"), &Timer::get_time_left); @@ -208,5 +214,5 @@ Timer::Timer() { one_shot = false; time_left = -1; processing = false; - active = true; + paused = false; } diff --git a/scene/main/timer.h b/scene/main/timer.h index 756b779717..53a2ddb2bd 100644..100755 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -39,7 +39,7 @@ class Timer : public Node { bool one_shot; bool autostart; bool processing; - bool active; + bool paused; double time_left; @@ -64,8 +64,11 @@ public: void start(); void stop(); - void set_active(bool p_active); - bool is_active() const; + + void set_paused(bool p_paused); + bool is_paused() const; + + bool is_stopped() const; float get_time_left() const; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index b419f4b6be..8e40911887 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -289,7 +289,7 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in offset = loop_end_fp - (loop_begin_fp - offset); } } else { - /* check for sample not reaching begining */ + /* check for sample not reaching beginning */ if (offset < 0) { active = false; diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 2a8fab7f4c..eae52d7bd4 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -135,7 +135,7 @@ public: float get_baked_length() const; Vector2 interpolate_baked(float p_offset, bool p_cubic = false) const; - PoolVector2Array get_baked_points() const; //useful for going thru + PoolVector2Array get_baked_points() const; //useful for going through PoolVector2Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display @@ -203,8 +203,8 @@ public: float get_baked_length() const; Vector3 interpolate_baked(float p_offset, bool p_cubic = false) const; float interpolate_baked_tilt(float p_offset) const; - PoolVector3Array get_baked_points() const; //useful for going thru - PoolRealArray get_baked_tilts() const; //useful for going thru + PoolVector3Array get_baked_points() const; //useful for going through + PoolRealArray get_baked_tilts() const; //useful for going through PoolVector3Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py index 68c9e92527..03c2c9be4a 100755 --- a/scene/resources/default_theme/make_header.py +++ b/scene/resources/default_theme/make_header.py @@ -8,7 +8,7 @@ import string f = open("theme_data.h", "wb") -f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n") +f.write("// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n") f.write("\n\n") diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 08ebb954b2..3fbfbc705a 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -29,6 +29,7 @@ #ifdef FREETYPE_ENABLED #include "dynamic_font.h" #include "os/file_access.h" +#include "os/os.h" bool DynamicFontData::CacheID::operator<(CacheID right) const { @@ -98,6 +99,7 @@ DynamicFontData::~DynamicFontData() { } //////////////////// +HashMap<String, Vector<uint8_t> > DynamicFontAtSize::_fontdata; Error DynamicFontAtSize::_load() { @@ -106,7 +108,29 @@ Error DynamicFontAtSize::_load() { ERR_EXPLAIN(TTR("Error initializing FreeType.")); ERR_FAIL_COND_V(error != 0, ERR_CANT_CREATE); - if (font->font_path != String()) { + // FT_OPEN_STREAM is extremely slow only on Android. + if (OS::get_singleton()->get_name() == "Android" && font->font_mem == NULL && font->font_path != String()) { + // cache font only once for each font->font_path + if (_fontdata.has(font->font_path)) { + + font->set_font_ptr(_fontdata[font->font_path].ptr(), _fontdata[font->font_path].size()); + + } else { + + FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); + ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); + + size_t len = f->get_len(); + _fontdata[font->font_path] = Vector<uint8_t>(); + Vector<uint8_t> &fontdata = _fontdata[font->font_path]; + fontdata.resize(len); + f->get_buffer(fontdata.ptr(), len); + font->set_font_ptr(fontdata.ptr(), len); + f->close(); + } + } + + if (font->font_mem == NULL && font->font_path != String()) { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 9502943909..4243ab2c03 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -141,6 +141,7 @@ class DynamicFontAtSize : public Reference { Ref<DynamicFontData> font; DynamicFontData::CacheID id; + static HashMap<String, Vector<uint8_t> > _fontdata; Error _load(); protected: diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 76c6543a2f..2bb9eda198 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -533,7 +533,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") { //property has requested that no instance state is saved, sorry - //also, meta won't be overriden or saved + //also, meta won't be overridden or saved continue; } diff --git a/scene/resources/shader.h b/scene/resources/shader.h index b7fa349dfe..bc98fbf737 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -54,7 +54,7 @@ private: // hack the name of performance // shaders keep a list of ShaderMaterial -> VisualServer name translations, to make - // convertion fast and save memory. + // conversion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName, StringName> params_cache; //map a shader param to a material param.. Map<StringName, Ref<Texture> > default_textures; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index f979c5c758..d08fc2634e 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -918,7 +918,7 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile } void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const { - //this might not necesarily work well if using a rect, needs to be fixed properly + //this might not necessarily work well if using a rect, needs to be fixed properly Rect2 rc = region; if (!atlas.is_valid()) |