Skip to content

Commit

Permalink
Merge pull request #50642 from akien-mga/3.x-cherrypicks
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jul 20, 2021
2 parents 028bf84 + fde7c2c commit 51f8247
Show file tree
Hide file tree
Showing 45 changed files with 1,198 additions and 733 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ if "env" in locals():
def print_elapsed_time():
elapsed_time_sec = round(time.time() - time_at_start, 3)
time_ms = round((elapsed_time_sec % 1) * 1000)
print(f"[Time elapsed: {time.strftime('%H:%M:%S', time.gmtime(elapsed_time_sec))}.{time_ms:03}]")
print("[Time elapsed: {}.{:03}]".format(time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)), time_ms))


atexit.register(print_elapsed_time)
4 changes: 1 addition & 3 deletions core/io/multiplayer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,7 @@ int MultiplayerAPI::get_network_unique_id() const {
}

bool MultiplayerAPI::is_network_server() const {
// XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier?
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. I can't be a server.");
return network_peer->is_server();
return network_peer.is_valid() && network_peer->is_server();
}

void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) {
Expand Down
6 changes: 6 additions & 0 deletions core/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static const char *locale_list[] = {
"ast_ES", // Asturian (Spain)
"ayc_PE", // Southern Aymara (Peru)
"ay_PE", // Aymara (Peru)
"az", // Azerbaijani
"az_AZ", // Azerbaijani (Azerbaijan)
"be", // Belarusian
"be_BY", // Belarusian (Belarus)
Expand Down Expand Up @@ -235,6 +236,7 @@ static const char *locale_list[] = {
"ka_GE", // Georgian (Georgia)
"kk_KZ", // Kazakh (Kazakhstan)
"kl_GL", // Kalaallisut (Greenland)
"km", // Central Khmer
"km_KH", // Central Khmer (Cambodia)
"kn_IN", // Kannada (India)
"kok_IN", // Konkani (India)
Expand Down Expand Up @@ -385,6 +387,7 @@ static const char *locale_list[] = {
"tr_CY", // Turkish (Cyprus)
"tr_TR", // Turkish (Turkey)
"ts_ZA", // Tsonga (South Africa)
"tt", // Tatar
"tt_RU", // Tatar (Russia)
"tzm", // Central Atlas Tamazight
"tzm_MA", // Central Atlas Tamazight (Marrocos)
Expand Down Expand Up @@ -453,6 +456,7 @@ static const char *locale_names[] = {
"Asturian (Spain)",
"Southern Aymara (Peru)",
"Aymara (Peru)",
"Azerbaijani",
"Azerbaijani (Azerbaijan)",
"Belarusian",
"Belarusian (Belarus)",
Expand Down Expand Up @@ -609,6 +613,7 @@ static const char *locale_names[] = {
"Georgian (Georgia)",
"Kazakh (Kazakhstan)",
"Kalaallisut (Greenland)",
"Central Khmer",
"Central Khmer (Cambodia)",
"Kannada (India)",
"Konkani (India)",
Expand Down Expand Up @@ -759,6 +764,7 @@ static const char *locale_names[] = {
"Turkish (Cyprus)",
"Turkish (Turkey)",
"Tsonga (South Africa)",
"Tatar",
"Tatar (Russia)",
"Central Atlas Tamazight",
"Central Atlas Tamazight (Marrocos)",
Expand Down
18 changes: 18 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,10 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
_playing_edited = p_current;
}

void EditorNode::_android_build_source_selected(const String &p_file) {
export_template_manager->install_android_template_from_file(p_file);
}

void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!p_confirmed) { //this may be a hack..
current_option = (MenuOptions)p_option;
Expand Down Expand Up @@ -2753,6 +2757,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
export_template_manager->popup_manager();

} break;
case SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE: {
custom_build_manage_templates->hide();
file_android_build_source->popup_centered_ratio();
} break;
case SETTINGS_MANAGE_FEATURE_PROFILES: {
feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8);
} break;
Expand Down Expand Up @@ -5513,6 +5521,7 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_unhandled_input", &EditorNode::_unhandled_input);
ClassDB::bind_method("_update_file_menu_opened", &EditorNode::_update_file_menu_opened);
ClassDB::bind_method("_update_file_menu_closed", &EditorNode::_update_file_menu_closed);
ClassDB::bind_method("_android_build_source_selected", &EditorNode::_android_build_source_selected);

ClassDB::bind_method(D_METHOD("push_item", "object", "property", "inspector_only"), &EditorNode::push_item, DEFVAL(""), DEFVAL(false));

Expand Down Expand Up @@ -6660,9 +6669,18 @@ EditorNode::EditorNode() {
custom_build_manage_templates = memnew(ConfirmationDialog);
custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates."));
custom_build_manage_templates->get_ok()->set_text(TTR("Manage Templates"));
custom_build_manage_templates->add_button(TTR("Install from file"))->connect("pressed", this, "_menu_option", varray(SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE));
custom_build_manage_templates->connect("confirmed", this, "_menu_option", varray(SETTINGS_MANAGE_EXPORT_TEMPLATES));
gui_base->add_child(custom_build_manage_templates);

file_android_build_source = memnew(EditorFileDialog);
file_android_build_source->set_title(TTR("Select android sources file"));
file_android_build_source->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_android_build_source->set_mode(EditorFileDialog::MODE_OPEN_FILE);
file_android_build_source->add_filter("*.zip");
file_android_build_source->connect("file_selected", this, "_android_build_source_selected");
gui_base->add_child(file_android_build_source);

install_android_build_template = memnew(ConfirmationDialog);
install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset."));
install_android_build_template->get_ok()->set_text(TTR("Install"));
Expand Down
4 changes: 4 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class EditorNode : public Node {
SETTINGS_EDITOR_CONFIG_FOLDER,
SETTINGS_MANAGE_EXPORT_TEMPLATES,
SETTINGS_MANAGE_FEATURE_PROFILES,
SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE,
SETTINGS_PICK_MAIN_SCENE,
SETTINGS_TOGGLE_CONSOLE,
SETTINGS_TOGGLE_FULLSCREEN,
Expand Down Expand Up @@ -332,6 +333,7 @@ class EditorNode : public Node {
EditorFileDialog *file_templates;
EditorFileDialog *file_export_lib;
EditorFileDialog *file_script;
EditorFileDialog *file_android_build_source;
CheckBox *file_export_lib_merge;
String current_path;
MenuButton *update_spinner;
Expand Down Expand Up @@ -456,6 +458,8 @@ class EditorNode : public Node {
void _menu_confirm_current();
void _menu_option_confirm(int p_option, bool p_confirmed);

void _android_build_source_selected(const String &p_file);

void _request_screenshot();
void _screenshot(bool p_use_utc = false);
void _save_screenshot(NodePath p_path);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void EditorProfiler::_update_frame() {
item->set_metadata(1, it.script);
item->set_metadata(2, it.line);
item->set_text_align(2, TreeItem::ALIGN_RIGHT);
item->set_tooltip(0, it.script + ":" + itos(it.line));
item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line));

float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total;

Expand Down
12 changes: 7 additions & 5 deletions editor/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,12 @@ bool ExportTemplateManager::can_install_android_template() {
}

Error ExportTemplateManager::install_android_template() {
const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
return install_android_template_from_file(source_zip);
}
Error ExportTemplateManager::install_android_template_from_file(const String &p_file) {
// To support custom Android builds, we install the Java source code and buildsystem
// from android_source.zip to the project's res://android folder.

Expand Down Expand Up @@ -675,14 +681,10 @@ Error ExportTemplateManager::install_android_template() {

// Uncompress source template.

const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);

FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");

int ret = unzGoToFirstFile(pkg);
Expand Down
2 changes: 2 additions & 0 deletions editor/export_template_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class ExportTemplateManager : public AcceptDialog {
bool can_install_android_template();
Error install_android_template();

Error install_android_template_from_file(const String &p_file);

void popup_manager();

ExportTemplateManager();
Expand Down
5 changes: 3 additions & 2 deletions editor/inspector_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void InspectorDock::_notification(int p_what) {
resource_new_button->set_icon(get_icon("New", "EditorIcons"));
resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
resource_save_button->set_icon(get_icon("Save", "EditorIcons"));
resource_extra_button->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
resource_extra_button->set_icon(get_icon("GuiTabMenuHl", "EditorIcons"));

PopupMenu *resource_extra_popup = resource_extra_button->get_popup();
resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_icon("ActionPaste", "EditorIcons"));
Expand Down Expand Up @@ -526,7 +526,8 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
resource_save_button->set_disabled(true);

resource_extra_button = memnew(MenuButton);
resource_extra_button->set_icon(get_icon("GuiTabMenu", "EditorIcons"));
resource_extra_button->set_icon(get_icon("GuiTabMenuHl", "EditorIcons"));
resource_extra_button->set_tooltip(TTR("Extra resource options."));
general_options_hb->add_child(resource_extra_button);
resource_extra_button->get_popup()->add_icon_shortcut(get_icon("ActionPaste", "EditorIcons"), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD);
resource_extra_button->get_popup()->add_icon_shortcut(get_icon("ActionCopy", "EditorIcons"), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY);
Expand Down
13 changes: 7 additions & 6 deletions editor/plugins/curve_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ int CurveEditor::get_point_at(Vector2 pos) const {
}
const Curve &curve = **_curve_ref;

const float r = _hover_radius * _hover_radius;
const float true_hover_radius = Math::round(_hover_radius * EDSCALE);
const float r = true_hover_radius * true_hover_radius;

for (int i = 0; i < curve.get_point_count(); ++i) {
Vector2 p = get_view_pos(curve.get_point_position(i));
Expand Down Expand Up @@ -554,7 +555,7 @@ Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const {
Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i));
Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir);

return point_pos + _tangents_length * (control_pos - point_pos).normalized();
return point_pos + Math::round(_tangents_length * EDSCALE) * (control_pos - point_pos).normalized();
}

Vector2 CurveEditor::get_view_pos(Vector2 world_pos) const {
Expand Down Expand Up @@ -698,13 +699,13 @@ void CurveEditor::_draw() {
if (i != 0) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT);
draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color);
}

if (i != curve.get_point_count() - 1) {
Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT);
draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE), true);
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color);
draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color);
}
}

Expand All @@ -727,7 +728,7 @@ void CurveEditor::_draw() {

for (int i = 0; i < curve.get_point_count(); ++i) {
Vector2 pos = curve.get_point_position(i);
draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(3), i == _selected_point ? selected_point_color : point_color);
draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * EDSCALE)), i == _selected_point ? selected_point_color : point_color);
// TODO Circles are prettier. Needs a fix! Or a texture
//draw_circle(pos, 2, point_color);
}
Expand All @@ -737,7 +738,7 @@ void CurveEditor::_draw() {
if (_hover_point != -1) {
const Color hover_color = line_color;
Vector2 pos = curve.get_point_position(_hover_point);
draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color, false, Math::round(EDSCALE));
draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * EDSCALE)), hover_color, false, Math::round(EDSCALE));
}

// Help text
Expand Down
4 changes: 4 additions & 0 deletions editor/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
}

void SceneTreeEditor::_node_renamed(Node *p_node) {
if (!get_scene_node()->is_a_parent_of(p_node)) {
return;
}

emit_signal("node_renamed");

if (!tree_dirty) {
Expand Down
Loading

0 comments on commit 51f8247

Please sign in to comment.