summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--editor/code_editor.cpp19
-rw-r--r--editor/editor_fonts.cpp61
-rw-r--r--editor/editor_settings.cpp24
-rw-r--r--editor/editor_settings.h2
-rw-r--r--editor/editor_themes.cpp91
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp36
-rw-r--r--modules/regex/regex.cpp27
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java5
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java2
-rw-r--r--platform/android/os_android.cpp32
-rw-r--r--platform/iphone/export/export.cpp2
-rw-r--r--platform/javascript/detect.py10
-rw-r--r--scene/gui/video_player.cpp8
-rw-r--r--scene/gui/video_player.h2
-rw-r--r--scene/resources/dynamic_font.cpp2
16 files changed, 175 insertions, 152 deletions
diff --git a/.gitignore b/.gitignore
index cbb0b5b133..f8296ef51e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,10 @@ gmon.out
.cproject
.settings/
+# Geany/geany-plugins files
+*.geany
+.geanyprj
+
# Misc
.DS_Store
logs/
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index feb5bf2a8f..3e079cb3ca 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1034,7 +1034,7 @@ void CodeTextEditor::_reset_zoom() {
Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
if (font.is_valid()) {
- EditorSettings::get_singleton()->set("interface/editor/source_font_size", 14);
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
font->set_size(14);
}
}
@@ -1098,7 +1098,7 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
if (font.is_valid()) {
int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE);
if (new_size != font->get_size()) {
- EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE);
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE);
font->set_size(new_size);
}
@@ -1140,20 +1140,7 @@ void CodeTextEditor::set_error(const String &p_error) {
void CodeTextEditor::_update_font() {
- // FONTS
- String editor_font = EDITOR_DEF("text_editor/theme/font", "");
- bool font_overridden = false;
- if (editor_font != "") {
- Ref<Font> fnt = ResourceLoader::load(editor_font);
- if (fnt.is_valid()) {
- text_editor->add_font_override("font", fnt);
- font_overridden = true;
- }
- }
- if (!font_overridden) {
-
- text_editor->add_font_override("font", get_font("source", "EditorFonts"));
- }
+ text_editor->add_font_override("font", get_font("source", "EditorFonts"));
}
void CodeTextEditor::_on_settings_change() {
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index c970ae355b..a58257962a 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -85,10 +85,24 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p
m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
+#define MAKE_SOURCE_FONT(m_name, m_size) \
+ Ref<DynamicFont> m_name; \
+ m_name.instance(); \
+ m_name->set_size(m_size); \
+ if (CustomFontSource.is_valid()) { \
+ m_name->set_font_data(CustomFontSource); \
+ m_name->add_fallback(dfmono); \
+ } else { \
+ m_name->set_font_data(dfmono); \
+ } \
+ m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
+ m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
+ MAKE_FALLBACKS(m_name);
+
void editor_register_fonts(Ref<Theme> p_theme) {
/* Custom font */
- String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font");
+ String custom_font = EditorSettings::get_singleton()->get("interface/editor/main_font");
Ref<DynamicFontData> CustomFont;
if (custom_font.length() > 0) {
CustomFont.instance();
@@ -96,6 +110,15 @@ void editor_register_fonts(Ref<Theme> p_theme) {
CustomFont->set_force_autohinter(true); //just looks better..i think?
}
+ /* Custom source code font */
+
+ String custom_font_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
+ Ref<DynamicFontData> CustomFontSource;
+ if (custom_font_source.length() > 0) {
+ CustomFontSource.instance();
+ CustomFontSource->set_font_path(custom_font_source);
+ }
+
/* Droid Sans */
Ref<DynamicFontData> DefaultFont;
@@ -135,7 +158,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size);
//dfd->set_force_autohinter(true); //just looks better..i think?
- int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE;
+ int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE;
MAKE_DEFAULT_FONT(df, default_font_size);
p_theme->set_default_theme_font(df);
@@ -153,41 +176,15 @@ void editor_register_fonts(Ref<Theme> p_theme) {
MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE);
p_theme->set_font("rulers", "EditorFonts", df_rulers);
- Ref<DynamicFont> df_code;
- df_code.instance();
- df_code->set_size(int(EditorSettings::get_singleton()->get("interface/editor/source_font_size")) * EDSCALE);
- df_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_code);
-
+ MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE);
p_theme->set_font("source", "EditorFonts", df_code);
- Ref<DynamicFont> df_doc_code;
- df_doc_code.instance();
- df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE);
- df_doc_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_doc_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_doc_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_doc_code);
-
+ MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE);
p_theme->set_font("doc_source", "EditorFonts", df_doc_code);
- Ref<DynamicFont> df_output_code;
- df_output_code.instance();
- df_output_code->set_size(int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE);
- df_output_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_output_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_output_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_output_code);
-
+ MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE);
p_theme->set_font("output_source", "EditorFonts", df_output_code);
- Ref<DynamicFont> df_text_editor_status_code;
- df_text_editor_status_code.instance();
- df_text_editor_status_code->set_size(14 * EDSCALE);
- df_text_editor_status_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_text_editor_status_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_text_editor_status_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_text_editor_status_code);
-
+ MAKE_SOURCE_FONT(df_text_editor_status_code, 14 * EDSCALE);
p_theme->set_font("status_source", "EditorFonts", df_text_editor_status_code);
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bcdd232260..7081bb925f 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -281,12 +281,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/hidpi_mode", 0);
hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/scene_tabs/show_script_button", false);
- _initial_set("interface/editor/font_size", 14);
- hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- _initial_set("interface/editor/source_font_size", 14);
- hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- _initial_set("interface/editor/custom_font", "");
- hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/main_font_size", 14);
+ hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/code_font_size", 14);
+ hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/main_font", "");
+ hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/code_font", "");
+ hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/dim_editor_on_dialog_popup", true);
_initial_set("interface/editor/dim_amount", 0.6f);
hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
@@ -375,8 +377,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1");
_initial_set("text_editor/cursor/right_click_moves_caret", true);
- _initial_set("text_editor/theme/font", "");
- hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res");
_initial_set("text_editor/completion/auto_brace_complete", false);
_initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true);
_initial_set("text_editor/completion/callhint_tooltip_offset", Vector2());
@@ -992,13 +992,17 @@ void EditorSettings::raise_order(const String &p_setting) {
props[p_setting].order = ++last_order;
}
-void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) {
+void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current) {
_THREAD_SAFE_METHOD_
if (!props.has(p_setting))
return;
- _initial_set(p_setting, p_value);
+ props[p_setting].initial = p_value;
+ props[p_setting].has_default_value = true;
+ if (update_current) {
+ set(p_setting, p_value);
+ }
}
Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) {
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 5fc49de0a7..914316ee61 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -145,7 +145,7 @@ public:
bool has_setting(const String &p_setting) const;
void erase(const String &p_setting);
void raise_order(const String &p_setting);
- void set_initial_value(const StringName &p_setting, const Variant &p_value);
+ void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false);
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
if (p_emit_signal)
_set(p_setting, p_value);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 0ebcef8e5e..9fda9d2ff6 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1063,38 +1063,67 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
EditorSettings *setting = EditorSettings::get_singleton();
String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
if (text_editor_color_theme == "Adaptive") {
- setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color);
- setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color);
- setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color);
- setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color);
- setting->set_initial_value("text_editor/highlighting/comment_color", comment_color);
- setting->set_initial_value("text_editor/highlighting/string_color", string_color);
- setting->set_initial_value("text_editor/highlighting/background_color", background_color);
- setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color);
- setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color);
- setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color);
- setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color);
- setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color);
- setting->set_initial_value("text_editor/highlighting/text_color", text_color);
- setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color);
- setting->set_initial_value("text_editor/highlighting/caret_color", caret_color);
- setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color);
- setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color);
- setting->set_initial_value("text_editor/highlighting/selection_color", selection_color);
- setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color);
- setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color);
- setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color);
- setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color);
- setting->set_initial_value("text_editor/highlighting/number_color", number_color);
- setting->set_initial_value("text_editor/highlighting/function_color", function_color);
- setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color);
- setting->set_initial_value("text_editor/highlighting/mark_color", mark_color);
- setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color);
- setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color);
- setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color);
- setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color);
+ setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
+ setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
+ setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
+ setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
+ setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
+ setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
+ setting->set_initial_value("text_editor/highlighting/background_color", background_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
+ setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
+ setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
+ setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
+ setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
+ setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
+ setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
+ setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
+ setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
+ setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
+ setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
+ setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
+ setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
+ setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
+ setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
+ setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
+ setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
+ setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
+ setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
} else if (text_editor_color_theme == "Default") {
- setting->load_text_editor_theme();
+ setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true);
+ setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true);
+ setting->set_initial_value("text_editor/highlighting/base_type_color", Color::html("a4ffd4"), true);
+ setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true);
+ setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true);
+ setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true);
+ setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/text_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/caret_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/caret_background_color", Color::html("000000"), true);
+ setting->set_initial_value("text_editor/highlighting/text_selected_color", Color::html("000000"), true);
+ setting->set_initial_value("text_editor/highlighting/selection_color", Color::html("6ca9c2"), true);
+ setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), true);
+ setting->set_initial_value("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), true);
+ setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true);
+ setting->set_initial_value("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true);
+ setting->set_initial_value("text_editor/highlighting/number_color", Color::html("EB9532"), true);
+ setting->set_initial_value("text_editor/highlighting/function_color", Color::html("66a2ce"), true);
+ setting->set_initial_value("text_editor/highlighting/member_variable_color", Color::html("e64e59"), true);
+ setting->set_initial_value("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true);
+ setting->set_initial_value("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2), true);
+ setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true);
+ setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true);
+ setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true);
}
return theme;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index a186782128..2a46aba207 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -340,7 +340,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const
// Grid
Point2 offset = grid_offset;
if (snap_relative) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) {
offset = Object::cast_to<Node2D>(selection[0])->get_global_position();
} else {
@@ -382,7 +382,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
drag = DRAG_PIVOT;
} else if (set_pivot_shortcut.is_valid() && set_pivot_shortcut->is_shortcut(p_ev) && drag == DRAG_NONE && can_move_pivot) {
if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
Vector2 mouse_pos = viewport->get_local_mouse_position();
if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
//just in case, make it work if over viewport
@@ -751,7 +751,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
undo_redo->create_action(TTR("Move Action"), UndoRedo::MERGE_ENDS);
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -811,7 +811,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
Rect2 r2;
r2.position = tl;
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -835,7 +835,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
int CanvasItemEditor::get_item_count() {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
int ic = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1002,7 +1002,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const
void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1527,7 +1527,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
bone_ik_list.clear();
} else {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
@@ -1608,7 +1608,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
} else {
undo_redo->create_action(TTR("Edit CanvasItem"));
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -1905,7 +1905,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
return;
}
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
@@ -2921,7 +2921,7 @@ void CanvasItemEditor::_draw_viewport() {
// hide/show buttons depending on the selection
bool all_locked = true;
bool all_group = true;
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
all_locked = false;
all_group = false;
@@ -2976,7 +2976,7 @@ void CanvasItemEditor::_notification(int p_what) {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
bool all_control = true;
bool has_control = false;
@@ -3277,7 +3277,7 @@ void CanvasItemEditor::_update_scroll(float) {
}
void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Change Anchors and Margins"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3321,7 +3321,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
}
void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3464,7 +3464,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
case LOCK_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3482,7 +3482,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case UNLOCK_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3502,7 +3502,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case GROUP_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3520,7 +3520,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case UNGROUP_SELECTED: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -3878,7 +3878,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_SET_IK_CHAIN: {
- List<Node *> &selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 9bcbc4c4ea..3fe7e36d45 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -343,15 +343,20 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
ERR_FAIL_COND_V(!is_valid(), String());
- String output;
- output.resize(p_subject.length());
+ // safety_zone is the number of chars we allocate in addition to the number of chars expected in order to
+ // guard against the PCRE API writing one additional \0 at the end. PCRE's API docs are unclear on whether
+ // PCRE understands outlength in pcre2_substitute() as counting an implicit additional terminating char or
+ // not. always allocating one char more than telling PCRE has us on the safe side.
+ const int safety_zone = 1;
+
+ PCRE2_SIZE olength = p_subject.length() + 1; // space for output string and one terminating \0 character
+ Vector<CharType> output;
+ output.resize(olength + safety_zone);
uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH;
if (p_all)
flags |= PCRE2_SUBSTITUTE_GLOBAL;
- PCRE2_SIZE olength = output.length();
-
PCRE2_SIZE length = p_subject.length();
if (p_end >= 0 && (uint32_t)p_end < length)
length = p_end;
@@ -363,15 +368,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str();
PCRE2_SPTR16 r = (PCRE2_SPTR16)p_replacement.c_str();
- PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.c_str();
+ PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.ptrw();
pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx);
int res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR16 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR16 *)output.ptrw();
res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -388,15 +393,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str();
PCRE2_SPTR32 r = (PCRE2_SPTR32)p_replacement.c_str();
- PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.c_str();
+ PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.ptrw();
pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx);
int res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR32 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR32 *)output.ptrw();
res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -407,7 +412,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
return String();
}
- return output;
+ return String(output.ptr(), olength);
}
bool RegEx::is_valid() const {
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 37f25cc839..b5b0afb9e0 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//@Override public boolean dispatchTouchEvent (MotionEvent event) {
public boolean gotTouchEvent(final MotionEvent event) {
- super.onTouchEvent(event);
final int evcount = event.getPointerCount();
if (evcount == 0)
return true;
@@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
arr[i * 3 + 1] = (int)event.getX(i);
arr[i * 3 + 2] = (int)event.getY(i);
}
+ final int pointer_idx = event.getPointerId(event.getActionIndex());
//System.out.printf("gaction: %d\n",event.getAction());
final int action = event.getAction() & MotionEvent.ACTION_MASK;
@@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
*/
} break;
case MotionEvent.ACTION_POINTER_UP: {
- final int indexPointUp = event.getActionIndex();
- final int pointer_idx = event.getPointerId(indexPointUp);
GodotLib.touch(4, pointer_idx, evcount, arr);
//System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case MotionEvent.ACTION_POINTER_DOWN: {
- int pointer_idx = event.getActionIndex();
GodotLib.touch(3, pointer_idx, evcount, arr);
//System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index ca4895a2be..0222758c2b 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
@Override
public boolean onTouchEvent(MotionEvent event) {
-
+ super.onTouchEvent(event);
return activity.gotTouchEvent(event);
};
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 93272a1000..23811f963a 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -444,25 +444,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
}
touch.clear();
}
-
} break;
- case 3: { // add tuchi
-
- ERR_FAIL_INDEX(p_pointer, p_points.size());
+ case 3: { // add touch
- TouchPos tp = p_points[p_pointer];
- touch.push_back(tp);
+ for (int i = 0; i < p_points.size(); i++) {
+ if (p_points[i].id == p_pointer) {
+ TouchPos tp = p_points[i];
+ touch.push_back(tp);
- Ref<InputEventScreenTouch> ev;
- ev.instance();
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
- ev->set_index(tp.id);
- ev->set_pressed(true);
- ev->set_position(tp.pos);
- input->parse_input_event(ev);
+ ev->set_index(tp.id);
+ ev->set_pressed(true);
+ ev->set_position(tp.pos);
+ input->parse_input_event(ev);
+ break;
+ }
+ }
} break;
- case 4: {
+ case 4: { // remove touch
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
@@ -474,10 +476,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
ev->set_position(touch[i].pos);
input->parse_input_event(ev);
touch.remove(i);
- i--;
+
+ break;
}
}
-
} break;
}
}
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 99d44f3b5e..e3119814f4 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -407,7 +407,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre
Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
if (err) {
memdelete(da);
- String err_str = String("Failed to export loading screen: ") + loading_screen_file;
+ String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file;
ERR_PRINT(err_str.utf8().get_data());
return err;
}
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 8472c3ccab..8c7a904bca 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -49,8 +49,14 @@ def configure(env):
## Build type
if (env["target"] == "release"):
- env.Append(CCFLAGS=['-O3'])
- env.Append(LINKFLAGS=['-O3'])
+ # Use -Os to prioritize optimizing for reduced file size. This is
+ # particularly valuable for the web platform because it directly
+ # decreases download time.
+ # -Os reduces file size by around 5 MiB over -O3. -Oz only saves about
+ # 100 KiB over -Os, which does not justify the negative impact on
+ # run-time performance.
+ env.Append(CCFLAGS=['-Os'])
+ env.Append(LINKFLAGS=['-Os'])
elif (env["target"] == "release_debug"):
env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 953ebe84f6..b0739a2f37 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -38,11 +38,6 @@ int VideoPlayer::sp_get_channel_count() const {
return playback->get_channels();
}
-void VideoPlayer::sp_set_mix_rate(int p_rate) {
-
- server_mix_rate = p_rate;
-}
-
bool VideoPlayer::mix(AudioFrame *p_buffer, int p_frames) {
// Check the amount resampler can really handle.
@@ -241,7 +236,7 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
AudioServer::get_singleton()->lock();
if (channels > 0)
- resampler.setup(channels, playback->get_mix_rate(), server_mix_rate, buffering_ms, 0);
+ resampler.setup(channels, playback->get_mix_rate(), AudioServer::get_singleton()->get_mix_rate(), buffering_ms, 0);
else
resampler.clear();
AudioServer::get_singleton()->unlock();
@@ -494,7 +489,6 @@ VideoPlayer::VideoPlayer() {
bus_index = 0;
buffering_ms = 500;
- server_mix_rate = 44100;
// internal_stream.player=this;
// stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 7010c71ad9..5c379b5620 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -50,7 +50,6 @@ class VideoPlayer : public Control {
Ref<VideoStream> stream;
int sp_get_channel_count() const;
- void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
bool mix(AudioFrame *p_buffer, int p_frames);
RID stream_rid;
@@ -69,7 +68,6 @@ class VideoPlayer : public Control {
bool expand;
bool loops;
int buffering_ms;
- int server_mix_rate;
int audio_track;
int bus_index;
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 00fc601779..575c222cc1 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -651,8 +651,8 @@ DynamicFontAtSize::~DynamicFontAtSize() {
if (valid) {
FT_Done_FreeType(library);
- font->size_cache.erase(id);
}
+ font->size_cache.erase(id);
}
/////////////////////////