diff options
-rw-r--r-- | doc/classes/SpriteFrames.xml | 2 | ||||
-rwxr-xr-x | doc/tools/makerst.py | 99 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 34 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.h | 1 | ||||
-rw-r--r-- | editor/editor_help.cpp | 56 | ||||
-rw-r--r-- | modules/mono/SCsub | 2 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 121 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 4 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/AABB.cs (renamed from modules/mono/glue/cs_files/AABB.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Array.cs (renamed from modules/mono/glue/cs_files/Array.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Attributes/ExportAttribute.cs (renamed from modules/mono/glue/cs_files/Attributes/ExportAttribute.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Attributes/GodotMethodAttribute.cs (renamed from modules/mono/glue/cs_files/Attributes/GodotMethodAttribute.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Attributes/RPCAttributes.cs (renamed from modules/mono/glue/cs_files/Attributes/RPCAttributes.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Attributes/SignalAttribute.cs (renamed from modules/mono/glue/cs_files/Attributes/SignalAttribute.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Attributes/ToolAttribute.cs (renamed from modules/mono/glue/cs_files/Attributes/ToolAttribute.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Basis.cs (renamed from modules/mono/glue/cs_files/Basis.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Color.cs (renamed from modules/mono/glue/cs_files/Color.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/DebuggingUtils.cs (renamed from modules/mono/glue/cs_files/DebuggingUtils.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Dictionary.cs (renamed from modules/mono/glue/cs_files/Dictionary.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs (renamed from modules/mono/glue/cs_files/Extensions/NodeExtensions.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Extensions/ObjectExtensions.cs (renamed from modules/mono/glue/cs_files/Extensions/ObjectExtensions.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs (renamed from modules/mono/glue/cs_files/Extensions/ResourceLoaderExtensions.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/GD.cs (renamed from modules/mono/glue/cs_files/GD.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/GodotSynchronizationContext.cs (renamed from modules/mono/glue/cs_files/GodotSynchronizationContext.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/GodotTaskScheduler.cs (renamed from modules/mono/glue/cs_files/GodotTaskScheduler.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Interfaces/IAwaitable.cs (renamed from modules/mono/glue/cs_files/Interfaces/IAwaitable.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Interfaces/IAwaiter.cs (renamed from modules/mono/glue/cs_files/Interfaces/IAwaiter.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/MarshalUtils.cs (renamed from modules/mono/glue/cs_files/MarshalUtils.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Mathf.cs (renamed from modules/mono/glue/cs_files/Mathf.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/MathfEx.cs (renamed from modules/mono/glue/cs_files/MathfEx.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/NodePath.cs (renamed from modules/mono/glue/cs_files/NodePath.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Object.base.cs (renamed from modules/mono/glue/cs_files/Object.base.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Plane.cs (renamed from modules/mono/glue/cs_files/Plane.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Quat.cs (renamed from modules/mono/glue/cs_files/Quat.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/RID.cs (renamed from modules/mono/glue/cs_files/RID.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Rect2.cs (renamed from modules/mono/glue/cs_files/Rect2.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/SignalAwaiter.cs (renamed from modules/mono/glue/cs_files/SignalAwaiter.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/StringExtensions.cs (renamed from modules/mono/glue/cs_files/StringExtensions.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Transform.cs (renamed from modules/mono/glue/cs_files/Transform.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Transform2D.cs (renamed from modules/mono/glue/cs_files/Transform2D.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector2.cs (renamed from modules/mono/glue/cs_files/Vector2.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector3.cs (renamed from modules/mono/glue/cs_files/Vector3.cs) | 0 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/Enums.cs | 21 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs | 17 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/Node.cs | 28 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/Resource.cs | 7 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs | 12 | ||||
-rw-r--r-- | modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs | 7 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Managed.csproj | 40 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Managed.sln | 17 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Properties/AssemblyInfo.cs | 26 | ||||
-rw-r--r-- | modules/mono/glue/Managed/README.md | 5 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 29 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.h | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 17 | ||||
-rw-r--r-- | scene/2d/animated_sprite.cpp | 69 | ||||
-rw-r--r-- | scene/2d/animated_sprite.h | 6 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 3 |
58 files changed, 484 insertions, 141 deletions
diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index 4ad575b67f..0e11d797e4 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -171,6 +171,8 @@ </method> </methods> <members> + <member name="frames" type="Array" setter="_set_frames" getter="_get_frames"> + </member> </members> <constants> </constants> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 93ad823d42..06b842d8e6 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -312,7 +312,7 @@ def rstize_text(text, cclass): def make_type(t): global class_names if t in class_names: - return ':ref:`' + t + '<class_' + t.lower() + '>`' + return ':ref:`' + t + '<class_' + t + '>`' return t @@ -332,7 +332,7 @@ def make_enum(t): c = "@GlobalScope" e = t if c in class_names: - return ':ref:`' + e + '<enum_' + c.lower() + '_' + e.lower() + '>`' + return ':ref:`' + e + '<enum_' + c + '_' + e + '>`' return t @@ -435,6 +435,8 @@ def make_rst_class(node): f.write(".. _class_" + name + ":\n\n") f.write(make_heading(name, '=')) + # Inheritance tree + # Ascendents if 'inherits' in node.attrib: inh = node.attrib['inherits'].strip() f.write('**Inherits:** ') @@ -451,35 +453,40 @@ def make_rst_class(node): inh = inode.attrib['inherits'].strip() else: inh = None + f.write("\n") - f.write("\n\n") - + # Descendents inherited = [] for cn in classes: c = classes[cn] if 'inherits' in c.attrib: if (c.attrib['inherits'].strip() == name): inherited.append(c.attrib['name']) - if (len(inherited)): f.write('**Inherited By:** ') for i in range(len(inherited)): if (i > 0): f.write(", ") f.write(make_type(inherited[i])) - f.write("\n\n") + f.write("\n") + + # Category if 'category' in node.attrib: f.write('**Category:** ' + node.attrib['category'].strip() + "\n\n") + # Brief description f.write(make_heading('Brief Description', '-')) briefd = node.find('brief_description') if briefd != None: f.write(rstize_text(briefd.text.strip(), name) + "\n\n") - methods = node.find('methods') + # Properties overview + # TODO: Implement + # Methods overview + methods = node.find('methods') if methods != None and len(list(methods)) > 0: - f.write(make_heading('Member Functions', '-')) + f.write(make_heading('Methods', '-')) ml = [] for m in list(methods): make_method(f, node.attrib['name'], m, False, name, False, ml) @@ -512,6 +519,10 @@ def make_rst_class(node): f.write(sep) f.write('\n') + # Theme properties + # TODO: Implement + + # Signals events = node.find('signals') if events != None and len(list(events)) > 0: f.write(make_heading('Signals', '-')) @@ -527,24 +538,7 @@ def make_rst_class(node): f.write('\n') - members = node.find('members') - if members != None and len(list(members)) > 0: - f.write(make_heading('Member Variables', '-')) - - for c in list(members): - # Leading two spaces necessary to prevent breaking the <ul> - f.write(" .. _class_" + name + "_" + c.attrib['name'] + ":\n\n") - s = '- ' - if 'enum' in c.attrib: - s += make_enum(c.attrib['enum']) + ' ' - else: - s += make_type(c.attrib['type']) + ' ' - s += '**' + c.attrib['name'] + '**' - if c.text.strip() != '': - s += ' - ' + rstize_text(c.text.strip(), name) - f.write(s + '\n\n') - f.write('\n') - + # Constants and enums constants = node.find('constants') consts = [] enum_names = set() @@ -557,20 +551,9 @@ def make_rst_class(node): else: consts.append(c) - if len(consts) > 0: - f.write(make_heading('Numeric Constants', '-')) - for c in list(consts): - s = '- ' - s += '**' + c.attrib['name'] + '**' - if 'value' in c.attrib: - s += ' = **' + c.attrib['value'] + '**' - if c.text.strip() != '': - s += ' --- ' + rstize_text(c.text.strip(), name) - f.write(s + '\n') - f.write('\n') - + # Enums if len(enum_names) > 0: - f.write(make_heading('Enums', '-')) + f.write(make_heading('Enumerations', '-')) for e in enum_names: f.write(" .. _enum_" + name + "_" + e + ":\n\n") f.write("enum **" + e + "**\n\n") @@ -587,11 +570,26 @@ def make_rst_class(node): f.write('\n') f.write('\n') + # Constants + if len(consts) > 0: + f.write(make_heading('Constants', '-')) + for c in list(consts): + s = '- ' + s += '**' + c.attrib['name'] + '**' + if 'value' in c.attrib: + s += ' = **' + c.attrib['value'] + '**' + if c.text.strip() != '': + s += ' --- ' + rstize_text(c.text.strip(), name) + f.write(s + '\n') + f.write('\n') + + # Class description descr = node.find('description') if descr != None and descr.text.strip() != '': f.write(make_heading('Description', '-')) f.write(rstize_text(descr.text.strip(), name) + "\n\n") + # Online tutorials global godot_docs_pattern tutorials = node.find('tutorials') if tutorials != None and len(tutorials) > 0: @@ -618,9 +616,30 @@ def make_rst_class(node): f.write("- `" + link + " <" + link + ">`_\n") f.write("\n") + # Property descriptions + # TODO: Add setter and getter like in-editor help + members = node.find('members') + if members != None and len(list(members)) > 0: + f.write(make_heading('Property Descriptions', '-')) + + for c in list(members): + # Leading two spaces necessary to prevent breaking the <ul> + f.write(" .. _class_" + name + "_" + c.attrib['name'] + ":\n\n") + s = '- ' + if 'enum' in c.attrib: + s += make_enum(c.attrib['enum']) + ' ' + else: + s += make_type(c.attrib['type']) + ' ' + s += '**' + c.attrib['name'] + '**' + if c.text.strip() != '': + s += ' - ' + rstize_text(c.text.strip(), name) + f.write(s + '\n\n') + f.write('\n') + + # Method descriptions methods = node.find('methods') if methods != None and len(list(methods)) > 0: - f.write(make_heading('Member Function Description', '-')) + f.write(make_heading('Method Descriptions', '-')) for m in list(methods): f.write(".. _class_" + name + "_" + m.attrib['name'] + ":\n\n") make_method(f, node.attrib['name'], m, True, name) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 947729f6f6..1e43651d54 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3098,40 +3098,6 @@ void RasterizerSceneGLES3::_copy_screen(bool p_invalidate_color, bool p_invalida glBindVertexArray(0); } -void RasterizerSceneGLES3::_copy_to_front_buffer(Environment *env) { - - //copy to front buffer - glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); - - glDepthMask(GL_FALSE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_BLEND); - glDepthFunc(GL_LEQUAL); - glColorMask(1, 1, 1, 1); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->buffers.diffuse); - - storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, true); - - if (!env) { - //no environment, simply convert from linear to srgb - storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB, true); - } else { - /* FIXME: Why are both statements equal? */ - storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB, true); - } - - storage->shaders.copy.bind(); - - _copy_screen(); - - //turn off everything used - storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB, false); - storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false); -} - void RasterizerSceneGLES3::_copy_texture_to_front_buffer(GLuint p_texture) { //copy to front buffer diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index cf387a69bc..b4c4a0558f 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -837,7 +837,6 @@ public: void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env); void _copy_screen(bool p_invalidate_color = false, bool p_invalidate_depth = false); - void _copy_to_front_buffer(Environment *env); void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 8d371714cf..5b9e7b29a9 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -776,6 +776,7 @@ void EditorHelp::_update_doc() { Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); String link_color_text = title_color.to_html(false); + // Class name section_line.push_back(Pair<String, int>(TTR("Top"), 0)); class_desc->push_font(doc_title_font); class_desc->push_color(title_color); @@ -787,18 +788,18 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->add_newline(); + // Inheritance tree + + // Ascendents if (cd.inherits != "") { class_desc->push_color(title_color); - class_desc->push_font(doc_title_font); + class_desc->push_font(doc_font); class_desc->add_text(TTR("Inherits:") + " "); class_desc->pop(); - class_desc->pop(); String inherits = cd.inherits; - class_desc->push_font(doc_font); - while (inherits != "") { _add_type(inherits); @@ -813,6 +814,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Descendents if (ClassDB::class_exists(cd.name)) { bool found = false; @@ -824,13 +826,10 @@ void EditorHelp::_update_doc() { if (!found) { class_desc->push_color(title_color); - class_desc->push_font(doc_title_font); + class_desc->push_font(doc_font); class_desc->add_text(TTR("Inherited by:") + " "); class_desc->pop(); - class_desc->pop(); - found = true; - class_desc->push_font(doc_font); } if (prev) { @@ -853,6 +852,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); class_desc->add_newline(); + // Brief description if (cd.brief_description != "") { class_desc->push_color(title_color); @@ -874,15 +874,16 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Properties overview Set<String> skip_methods; bool property_descr = false; if (cd.properties.size()) { - section_line.push_back(Pair<String, int>(TTR("Members"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Members:")); + class_desc->add_text(TTR("Properties:")); class_desc->pop(); class_desc->pop(); @@ -940,6 +941,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Methods overview bool method_descr = false; bool sort_methods = EditorSettings::get_singleton()->get("text_editor/help/sort_functions_alphabetically"); @@ -956,10 +958,10 @@ void EditorHelp::_update_doc() { if (sort_methods) methods.sort(); - section_line.push_back(Pair<String, int>(TTR("Public Methods"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Public Methods:")); + class_desc->add_text(TTR("Methods:")); class_desc->pop(); class_desc->pop(); @@ -1024,22 +1026,20 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Theme properties if (cd.theme_properties.size()) { - section_line.push_back(Pair<String, int>(TTR("GUI Theme Items"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("GUI Theme Items:")); + class_desc->add_text(TTR("Theme Properties:")); class_desc->pop(); class_desc->pop(); - // class_desc->add_newline(); class_desc->push_indent(1); class_desc->push_table(2); class_desc->set_table_column_expand(1, 1); - //class_desc->add_newline(); - for (int i = 0; i < cd.theme_properties.size(); i++) { theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description @@ -1076,6 +1076,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Signals if (cd.signals.size()) { if (sort_methods) { @@ -1144,6 +1145,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Constants and enums if (cd.constants.size()) { Map<String, Vector<DocData::ConstantDoc> > enums; @@ -1163,6 +1165,7 @@ void EditorHelp::_update_doc() { } } + // Enums if (enums.size()) { section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2)); @@ -1245,6 +1248,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Constants if (constants.size()) { section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2)); @@ -1303,13 +1307,14 @@ void EditorHelp::_update_doc() { } } + // Class description if (cd.description != "") { - section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Class Description"), class_desc->get_line_count() - 2)); description_line = class_desc->get_line_count() - 2; class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Description:")); + class_desc->add_text(TTR("Class Description:")); class_desc->pop(); class_desc->pop(); @@ -1326,8 +1331,8 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); } + // Online tutorials { - class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Online Tutorials:")); @@ -1365,12 +1370,14 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); class_desc->add_newline(); } + + // Property descriptions if (property_descr) { - section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Property Description:")); + class_desc->add_text(TTR("Property Descriptions:")); class_desc->pop(); class_desc->pop(); @@ -1458,12 +1465,13 @@ void EditorHelp::_update_doc() { } } + // Method descriptions if (method_descr) { - section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2)); + section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Method Description:")); + class_desc->add_text(TTR("Method Descriptions:")); class_desc->pop(); class_desc->pop(); diff --git a/modules/mono/SCsub b/modules/mono/SCsub index a8e19db022..b3a2d26e4a 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -77,7 +77,7 @@ env_mono.add_source_files(env.modules_sources, 'utils/*.cpp') if env['tools']: env_mono.add_source_files(env.modules_sources, 'editor/*.cpp') # NOTE: It is safe to generate this file here, since this is still executed serially - make_cs_files_header('glue/cs_files', 'glue/cs_compressed.gen.h', 'glue/cs_glue_version.gen.h') + make_cs_files_header('glue/Managed/Files', 'glue/cs_compressed.gen.h', 'glue/cs_glue_version.gen.h') vars = Variables() vars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True)) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index f15114ef1d..b9209fce92 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1456,7 +1456,7 @@ MonoObject *CSharpInstance::_internal_new_managed() { return mono_object; } -bool CSharpInstance::mono_object_disposed(MonoObject *p_obj) { +void CSharpInstance::mono_object_disposed(MonoObject *p_obj) { #ifdef DEBUG_ENABLED CRASH_COND(base_ref == true); @@ -1465,7 +1465,7 @@ bool CSharpInstance::mono_object_disposed(MonoObject *p_obj) { CSharpLanguage::get_singleton()->release_script_gchandle(p_obj, gchandle); } -bool CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_owner_deleted) { +void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_owner_deleted) { #ifdef DEBUG_ENABLED CRASH_COND(base_ref == false); @@ -1928,6 +1928,10 @@ bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Ve } #ifdef TOOLS_ENABLED +/** + * Returns false if there was an error, otherwise true. + * If there was an error, r_prop_info and r_exported are not assigned any value. + */ bool CSharpScript::_get_member_export(GDMonoClass *p_class, GDMonoClassMember *p_member, PropertyInfo &r_prop_info, bool &r_exported) { StringName name = p_member->get_name(); @@ -1953,49 +1957,100 @@ bool CSharpScript::_get_member_export(GDMonoClass *p_class, GDMonoClassMember *p Variant::Type variant_type = GDMonoMarshal::managed_to_variant_type(type); - if (p_member->has_attribute(CACHED_CLASS(ExportAttribute))) { - if (p_member->get_member_type() == GDMonoClassMember::MEMBER_TYPE_PROPERTY) { - GDMonoProperty *property = static_cast<GDMonoProperty *>(p_member); - if (!property->has_getter() || !property->has_setter()) { - ERR_PRINTS("Cannot export property because it does not provide a getter or a setter: " + p_class->get_full_name() + "." + name.operator String()); - return false; - } + if (!p_member->has_attribute(CACHED_CLASS(ExportAttribute))) { + r_prop_info = PropertyInfo(variant_type, name.operator String(), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_SCRIPT_VARIABLE); + r_exported = false; + return true; + } + + if (p_member->get_member_type() == GDMonoClassMember::MEMBER_TYPE_PROPERTY) { + GDMonoProperty *property = static_cast<GDMonoProperty *>(p_member); + if (!property->has_getter() || !property->has_setter()) { + ERR_PRINTS("Cannot export property because it does not provide a getter or a setter: " + p_class->get_full_name() + "." + name.operator String()); + return false; } + } - MonoObject *attr = p_member->get_attribute(CACHED_CLASS(ExportAttribute)); + MonoObject *attr = p_member->get_attribute(CACHED_CLASS(ExportAttribute)); - PropertyHint hint = PROPERTY_HINT_NONE; - String hint_string; + PropertyHint hint = PROPERTY_HINT_NONE; + String hint_string; - if (variant_type == Variant::NIL) { - ERR_PRINTS("Unknown type of exported member: " + p_class->get_full_name() + "." + name.operator String()); - return false; - } else if (variant_type == Variant::INT && type.type_encoding == MONO_TYPE_VALUETYPE && mono_class_is_enum(type.type_class->get_mono_ptr())) { - variant_type = Variant::INT; - hint = PROPERTY_HINT_ENUM; + if (variant_type == Variant::NIL) { + ERR_PRINTS("Unknown type of exported member: " + p_class->get_full_name() + "." + name.operator String()); + return false; + } else if (variant_type == Variant::INT && type.type_encoding == MONO_TYPE_VALUETYPE && mono_class_is_enum(type.type_class->get_mono_ptr())) { + variant_type = Variant::INT; + hint = PROPERTY_HINT_ENUM; + + Vector<MonoClassField *> fields = type.type_class->get_enum_fields(); - Vector<MonoClassField *> fields = type.type_class->get_enum_fields(); + MonoType *enum_basetype = mono_class_enum_basetype(type.type_class->get_mono_ptr()); - for (int i = 0; i < fields.size(); i++) { - if (i > 0) - hint_string += ","; - hint_string += mono_field_get_name(fields[i]); + String name_only_hint_string; + + // True: enum Foo { Bar, Baz, Quux } + // True: enum Foo { Bar = 0, Baz = 1, Quux = 2 } + // False: enum Foo { Bar = 0, Baz = 7, Quux = 5 } + bool uses_default_values = true; + + for (int i = 0; i < fields.size(); i++) { + MonoClassField *field = fields[i]; + + if (i > 0) { + hint_string += ","; + name_only_hint_string += ","; } - } else if (variant_type == Variant::OBJECT && CACHED_CLASS(GodotReference)->is_assignable_from(type.type_class)) { - hint = PROPERTY_HINT_RESOURCE_TYPE; - hint_string = NATIVE_GDMONOCLASS_NAME(type.type_class); - } else { - hint = PropertyHint(CACHED_FIELD(ExportAttribute, hint)->get_int_value(attr)); - hint_string = CACHED_FIELD(ExportAttribute, hintString)->get_string_value(attr); + + String enum_field_name = mono_field_get_name(field); + hint_string += enum_field_name; + name_only_hint_string += enum_field_name; + + // TODO: + // Instead of using mono_field_get_value_object, we can do this without boxing. Check the + // internal mono functions: ves_icall_System_Enum_GetEnumValuesAndNames and the get_enum_field. + + MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, NULL); + + if (val_obj == NULL) { + ERR_PRINTS("Failed to get '" + enum_field_name + "' constant enum value of exported member: " + + p_class->get_full_name() + "." + name.operator String()); + return false; + } + + bool r_error; + uint64_t val = GDMonoUtils::unbox_enum_value(val_obj, enum_basetype, r_error); + if (r_error) { + ERR_PRINTS("Failed to unbox '" + enum_field_name + "' constant enum value of exported member: " + + p_class->get_full_name() + "." + name.operator String()); + return false; + } + + if (val != i) { + uses_default_values = false; + } + + hint_string += ":"; + hint_string += String::num_uint64(val); } - r_prop_info = PropertyInfo(variant_type, name.operator String(), hint, hint_string, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE); - r_exported = true; + if (uses_default_values) { + // If we use the format NAME:VAL, that's what the editor displays. + // That's annoying if the user is not using custom values for the enum constants. + // This may not be needed in the future if the editor is changed to not display values. + hint_string = name_only_hint_string; + } + } else if (variant_type == Variant::OBJECT && CACHED_CLASS(GodotReference)->is_assignable_from(type.type_class)) { + hint = PROPERTY_HINT_RESOURCE_TYPE; + hint_string = NATIVE_GDMONOCLASS_NAME(type.type_class); } else { - r_prop_info = PropertyInfo(variant_type, name.operator String(), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_SCRIPT_VARIABLE); - r_exported = false; + hint = PropertyHint(CACHED_FIELD(ExportAttribute, hint)->get_int_value(attr)); + hint_string = CACHED_FIELD(ExportAttribute, hintString)->get_string_value(attr); } + r_prop_info = PropertyInfo(variant_type, name.operator String(), hint, hint_string, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SCRIPT_VARIABLE); + r_exported = true; + return true; } #endif diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index fa399bb187..8b0a095890 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -215,8 +215,8 @@ public: virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount); virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount); - bool mono_object_disposed(MonoObject *p_obj); - bool mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_owner_deleted); + void mono_object_disposed(MonoObject *p_obj); + void mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_owner_deleted); virtual void refcount_incremented(); virtual bool refcount_decremented(); diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/Managed/Files/AABB.cs index 66490b5e25..66490b5e25 100644 --- a/modules/mono/glue/cs_files/AABB.cs +++ b/modules/mono/glue/Managed/Files/AABB.cs diff --git a/modules/mono/glue/cs_files/Array.cs b/modules/mono/glue/Managed/Files/Array.cs index c80cb7cc83..c80cb7cc83 100644 --- a/modules/mono/glue/cs_files/Array.cs +++ b/modules/mono/glue/Managed/Files/Array.cs diff --git a/modules/mono/glue/cs_files/Attributes/ExportAttribute.cs b/modules/mono/glue/Managed/Files/Attributes/ExportAttribute.cs index 6adf044886..6adf044886 100644 --- a/modules/mono/glue/cs_files/Attributes/ExportAttribute.cs +++ b/modules/mono/glue/Managed/Files/Attributes/ExportAttribute.cs diff --git a/modules/mono/glue/cs_files/Attributes/GodotMethodAttribute.cs b/modules/mono/glue/Managed/Files/Attributes/GodotMethodAttribute.cs index 55848769d5..55848769d5 100644 --- a/modules/mono/glue/cs_files/Attributes/GodotMethodAttribute.cs +++ b/modules/mono/glue/Managed/Files/Attributes/GodotMethodAttribute.cs diff --git a/modules/mono/glue/cs_files/Attributes/RPCAttributes.cs b/modules/mono/glue/Managed/Files/Attributes/RPCAttributes.cs index 6bf9560bfa..6bf9560bfa 100644 --- a/modules/mono/glue/cs_files/Attributes/RPCAttributes.cs +++ b/modules/mono/glue/Managed/Files/Attributes/RPCAttributes.cs diff --git a/modules/mono/glue/cs_files/Attributes/SignalAttribute.cs b/modules/mono/glue/Managed/Files/Attributes/SignalAttribute.cs index 3957387be9..3957387be9 100644 --- a/modules/mono/glue/cs_files/Attributes/SignalAttribute.cs +++ b/modules/mono/glue/Managed/Files/Attributes/SignalAttribute.cs diff --git a/modules/mono/glue/cs_files/Attributes/ToolAttribute.cs b/modules/mono/glue/Managed/Files/Attributes/ToolAttribute.cs index d0437409af..d0437409af 100644 --- a/modules/mono/glue/cs_files/Attributes/ToolAttribute.cs +++ b/modules/mono/glue/Managed/Files/Attributes/ToolAttribute.cs diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/Managed/Files/Basis.cs index ec96a9e2fa..ec96a9e2fa 100644 --- a/modules/mono/glue/cs_files/Basis.cs +++ b/modules/mono/glue/Managed/Files/Basis.cs diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/Managed/Files/Color.cs index 88cb8524b8..88cb8524b8 100644 --- a/modules/mono/glue/cs_files/Color.cs +++ b/modules/mono/glue/Managed/Files/Color.cs diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/Managed/Files/DebuggingUtils.cs index b27816084e..b27816084e 100644 --- a/modules/mono/glue/cs_files/DebuggingUtils.cs +++ b/modules/mono/glue/Managed/Files/DebuggingUtils.cs diff --git a/modules/mono/glue/cs_files/Dictionary.cs b/modules/mono/glue/Managed/Files/Dictionary.cs index 523e48c31a..523e48c31a 100644 --- a/modules/mono/glue/cs_files/Dictionary.cs +++ b/modules/mono/glue/Managed/Files/Dictionary.cs diff --git a/modules/mono/glue/cs_files/Extensions/NodeExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs index 71534d7782..71534d7782 100644 --- a/modules/mono/glue/cs_files/Extensions/NodeExtensions.cs +++ b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs diff --git a/modules/mono/glue/cs_files/Extensions/ObjectExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/ObjectExtensions.cs index 9ef0959750..9ef0959750 100644 --- a/modules/mono/glue/cs_files/Extensions/ObjectExtensions.cs +++ b/modules/mono/glue/Managed/Files/Extensions/ObjectExtensions.cs diff --git a/modules/mono/glue/cs_files/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs index ceecc589e6..ceecc589e6 100644 --- a/modules/mono/glue/cs_files/Extensions/ResourceLoaderExtensions.cs +++ b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/Managed/Files/GD.cs index 264be23588..264be23588 100644 --- a/modules/mono/glue/cs_files/GD.cs +++ b/modules/mono/glue/Managed/Files/GD.cs diff --git a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs b/modules/mono/glue/Managed/Files/GodotSynchronizationContext.cs index e727781d63..e727781d63 100644 --- a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs +++ b/modules/mono/glue/Managed/Files/GodotSynchronizationContext.cs diff --git a/modules/mono/glue/cs_files/GodotTaskScheduler.cs b/modules/mono/glue/Managed/Files/GodotTaskScheduler.cs index 9a40fef5a9..9a40fef5a9 100644 --- a/modules/mono/glue/cs_files/GodotTaskScheduler.cs +++ b/modules/mono/glue/Managed/Files/GodotTaskScheduler.cs diff --git a/modules/mono/glue/cs_files/Interfaces/IAwaitable.cs b/modules/mono/glue/Managed/Files/Interfaces/IAwaitable.cs index 0397957d00..0397957d00 100644 --- a/modules/mono/glue/cs_files/Interfaces/IAwaitable.cs +++ b/modules/mono/glue/Managed/Files/Interfaces/IAwaitable.cs diff --git a/modules/mono/glue/cs_files/Interfaces/IAwaiter.cs b/modules/mono/glue/Managed/Files/Interfaces/IAwaiter.cs index d3be9d781c..d3be9d781c 100644 --- a/modules/mono/glue/cs_files/Interfaces/IAwaiter.cs +++ b/modules/mono/glue/Managed/Files/Interfaces/IAwaiter.cs diff --git a/modules/mono/glue/cs_files/MarshalUtils.cs b/modules/mono/glue/Managed/Files/MarshalUtils.cs index f7699a15bf..f7699a15bf 100644 --- a/modules/mono/glue/cs_files/MarshalUtils.cs +++ b/modules/mono/glue/Managed/Files/MarshalUtils.cs diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/Managed/Files/Mathf.cs index a89dfe5f27..a89dfe5f27 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/Managed/Files/Mathf.cs diff --git a/modules/mono/glue/cs_files/MathfEx.cs b/modules/mono/glue/Managed/Files/MathfEx.cs index 739b7fb568..739b7fb568 100644 --- a/modules/mono/glue/cs_files/MathfEx.cs +++ b/modules/mono/glue/Managed/Files/MathfEx.cs diff --git a/modules/mono/glue/cs_files/NodePath.cs b/modules/mono/glue/Managed/Files/NodePath.cs index 2c89bec87f..2c89bec87f 100644 --- a/modules/mono/glue/cs_files/NodePath.cs +++ b/modules/mono/glue/Managed/Files/NodePath.cs diff --git a/modules/mono/glue/cs_files/Object.base.cs b/modules/mono/glue/Managed/Files/Object.base.cs index 30490a715f..30490a715f 100644 --- a/modules/mono/glue/cs_files/Object.base.cs +++ b/modules/mono/glue/Managed/Files/Object.base.cs diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/Managed/Files/Plane.cs index 9611dce11e..9611dce11e 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/Managed/Files/Plane.cs diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/Managed/Files/Quat.cs index eaa027eb69..eaa027eb69 100644 --- a/modules/mono/glue/cs_files/Quat.cs +++ b/modules/mono/glue/Managed/Files/Quat.cs diff --git a/modules/mono/glue/cs_files/RID.cs b/modules/mono/glue/Managed/Files/RID.cs index b862b8cac0..b862b8cac0 100644 --- a/modules/mono/glue/cs_files/RID.cs +++ b/modules/mono/glue/Managed/Files/RID.cs diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/Managed/Files/Rect2.cs index cb25c267bc..cb25c267bc 100644 --- a/modules/mono/glue/cs_files/Rect2.cs +++ b/modules/mono/glue/Managed/Files/Rect2.cs diff --git a/modules/mono/glue/cs_files/SignalAwaiter.cs b/modules/mono/glue/Managed/Files/SignalAwaiter.cs index 9483b6ffb4..9483b6ffb4 100644 --- a/modules/mono/glue/cs_files/SignalAwaiter.cs +++ b/modules/mono/glue/Managed/Files/SignalAwaiter.cs diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs index 21c9be98c1..21c9be98c1 100644 --- a/modules/mono/glue/cs_files/StringExtensions.cs +++ b/modules/mono/glue/Managed/Files/StringExtensions.cs diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/Managed/Files/Transform.cs index e432d5b52c..e432d5b52c 100644 --- a/modules/mono/glue/cs_files/Transform.cs +++ b/modules/mono/glue/Managed/Files/Transform.cs diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/Managed/Files/Transform2D.cs index 8d30833066..8d30833066 100644 --- a/modules/mono/glue/cs_files/Transform2D.cs +++ b/modules/mono/glue/Managed/Files/Transform2D.cs diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs index 080b8802ba..080b8802ba 100644 --- a/modules/mono/glue/cs_files/Vector2.cs +++ b/modules/mono/glue/Managed/Files/Vector2.cs diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs index 6fffe5e4d6..6fffe5e4d6 100644 --- a/modules/mono/glue/cs_files/Vector3.cs +++ b/modules/mono/glue/Managed/Files/Vector3.cs diff --git a/modules/mono/glue/Managed/IgnoredFiles/Enums.cs b/modules/mono/glue/Managed/IgnoredFiles/Enums.cs new file mode 100644 index 0000000000..05f1abcf93 --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/Enums.cs @@ -0,0 +1,21 @@ + +namespace Godot +{ + public enum Margin + { + Left = 0, + Top = 1, + Right = 2, + Bottom = 3 + } + + public enum Error + { + Ok = 0 + } + + public enum PropertyHint + { + None = 0 + } +} diff --git a/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs b/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs new file mode 100644 index 0000000000..83504fe49f --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/FuncRef.cs @@ -0,0 +1,17 @@ +using System; + +namespace Godot +{ + public partial class FuncRef + { + public void SetInstance(Object instance) + { + throw new NotImplementedException(); + } + + public void SetFunction(string name) + { + throw new NotImplementedException(); + } + } +} diff --git a/modules/mono/glue/Managed/IgnoredFiles/Node.cs b/modules/mono/glue/Managed/IgnoredFiles/Node.cs new file mode 100644 index 0000000000..99ba0f827a --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/Node.cs @@ -0,0 +1,28 @@ + +using System; + +namespace Godot +{ + public partial class Node + { + public Node GetChild(int idx) + { + throw new NotImplementedException(); + } + + public Node GetNode(NodePath path) + { + throw new NotImplementedException(); + } + + public Node GetOwner() + { + throw new NotImplementedException(); + } + + public Node GetParent() + { + throw new NotImplementedException(); + } + } +} diff --git a/modules/mono/glue/Managed/IgnoredFiles/Resource.cs b/modules/mono/glue/Managed/IgnoredFiles/Resource.cs new file mode 100644 index 0000000000..cc0a5555b1 --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/Resource.cs @@ -0,0 +1,7 @@ +namespace Godot +{ + public partial class Resource + { + + } +} diff --git a/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs b/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs new file mode 100644 index 0000000000..6461d35146 --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/ResourceLoader.cs @@ -0,0 +1,12 @@ +using System; + +namespace Godot +{ + public partial class ResourceLoader + { + public static Resource Load(string path, string typeHint = "", bool pNoCache = false) + { + throw new NotImplementedException(); + } + } +} diff --git a/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs b/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs new file mode 100644 index 0000000000..1498b7836b --- /dev/null +++ b/modules/mono/glue/Managed/IgnoredFiles/WeakRef.cs @@ -0,0 +1,7 @@ +namespace Godot +{ + public partial class WeakRef + { + + } +} diff --git a/modules/mono/glue/Managed/Managed.csproj b/modules/mono/glue/Managed/Managed.csproj new file mode 100644 index 0000000000..1f82dde5e7 --- /dev/null +++ b/modules/mono/glue/Managed/Managed.csproj @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProjectGuid>{DAA3DEF8-5112-407C-A5E5-6C608CF5F955}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>Managed</RootNamespace> + <AssemblyName>Managed</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ExternalConsole>true</ExternalConsole> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ExternalConsole>true</ExternalConsole> + <PlatformTarget>x86</PlatformTarget> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Files\**\*.cs" /> + <Compile Include="IgnoredFiles\**\*.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> +</Project> diff --git a/modules/mono/glue/Managed/Managed.sln b/modules/mono/glue/Managed/Managed.sln new file mode 100644 index 0000000000..61ddde0fb7 --- /dev/null +++ b/modules/mono/glue/Managed/Managed.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Managed", "Managed.csproj", "{DAA3DEF8-5112-407C-A5E5-6C608CF5F955}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Debug|x86.ActiveCfg = Debug|x86 + {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Debug|x86.Build.0 = Debug|x86 + {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Release|x86.ActiveCfg = Release|x86 + {DAA3DEF8-5112-407C-A5E5-6C608CF5F955}.Release|x86.Build.0 = Release|x86 + EndGlobalSection +EndGlobal diff --git a/modules/mono/glue/Managed/Properties/AssemblyInfo.cs b/modules/mono/glue/Managed/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7ed68acad7 --- /dev/null +++ b/modules/mono/glue/Managed/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("Managed")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/modules/mono/glue/Managed/README.md b/modules/mono/glue/Managed/README.md new file mode 100644 index 0000000000..65e63cae37 --- /dev/null +++ b/modules/mono/glue/Managed/README.md @@ -0,0 +1,5 @@ +The directory `Files` contains C# files from the core assembly project that are not part of the generated API. Any file with the `.cs` extension in this directory will be added to the core assembly project. + +A dummy solution and project is provided to get tooling help while editing these files, like code completion and name refactoring. + +The directory `IgnoredFiles` contains C# files that are needed to build the dummy project but must not be added to the core assembly project. They contain placeholders for the declarations that are part of the generated API. diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index cc5b5652f8..8fbaca0992 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -663,4 +663,33 @@ MonoObject *property_get_value(MonoProperty *p_prop, void *p_obj, void **p_param return ret; } +uint64_t unbox_enum_value(MonoObject *p_boxed, MonoType *p_enum_basetype, bool &r_error) { + r_error = false; + switch (mono_type_get_type(p_enum_basetype)) { + case MONO_TYPE_BOOLEAN: + return (bool)GDMonoMarshal::unbox<MonoBoolean>(p_boxed) ? 1 : 0; + case MONO_TYPE_CHAR: + return GDMonoMarshal::unbox<uint16_t>(p_boxed); + case MONO_TYPE_U1: + return GDMonoMarshal::unbox<uint8_t>(p_boxed); + case MONO_TYPE_U2: + return GDMonoMarshal::unbox<uint16_t>(p_boxed); + case MONO_TYPE_U4: + return GDMonoMarshal::unbox<uint32_t>(p_boxed); + case MONO_TYPE_U8: + return GDMonoMarshal::unbox<uint64_t>(p_boxed); + case MONO_TYPE_I1: + return GDMonoMarshal::unbox<int8_t>(p_boxed); + case MONO_TYPE_I2: + return GDMonoMarshal::unbox<int16_t>(p_boxed); + case MONO_TYPE_I4: + return GDMonoMarshal::unbox<int32_t>(p_boxed); + case MONO_TYPE_I8: + return GDMonoMarshal::unbox<int64_t>(p_boxed); + default: + r_error = true; + return 0; + } +} + } // namespace GDMonoUtils diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index c8e23f071f..96ff3e8116 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -240,6 +240,8 @@ MonoString *object_to_string(MonoObject *p_obj, MonoException **p_exc); void property_set_value(MonoProperty *p_prop, void *p_obj, void **p_params, MonoException **p_exc); MonoObject *property_get_value(MonoProperty *p_prop, void *p_obj, void **p_params, MonoException **p_exc); +uint64_t unbox_enum_value(MonoObject *p_boxed, MonoType *p_enum_basetype, bool &r_error); + } // namespace GDMonoUtils #define NATIVE_GDMONOCLASS_NAME(m_class) (GDMonoMarshal::mono_string_to_godot((MonoString *)m_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL))) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 20c9dd6290..b80a20ce40 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -744,12 +744,15 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) { ERR_PRINT("NO GRAB"); } - center.x = current_videomode.width / 2; - center.y = current_videomode.height / 2; - XWarpPointer(x11_display, None, x11_window, - 0, 0, 0, 0, (int)center.x, (int)center.y); + if (mouse_mode == MOUSE_MODE_CAPTURED) { + center.x = current_videomode.width / 2; + center.y = current_videomode.height / 2; + + XWarpPointer(x11_display, None, x11_window, + 0, 0, 0, 0, (int)center.x, (int)center.y); - input->set_mouse_position(center); + input->set_mouse_position(center); + } } else { do_mouse_warp = false; } @@ -2067,6 +2070,10 @@ void OS_X11::process_xevents() { Point2i rel = pos - last_mouse_pos; + if (mouse_mode == MOUSE_MODE_CAPTURED) { + pos = Point2i(current_videomode.width / 2, current_videomode.height / 2); + } + Ref<InputEventMouseMotion> mm; mm.instance(); diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 790606a0b2..a33fc844a5 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -227,6 +227,65 @@ bool SpriteFrames::get_animation_loop(const StringName &p_anim) const { return E->get().loop; } +void SpriteFrames::_set_frames(const Array &p_frames) { + + clear_all(); + Map<StringName, Anim>::Element *E = animations.find(SceneStringNames::get_singleton()->_default); + ERR_FAIL_COND(!E); + + E->get().frames.resize(p_frames.size()); + for (int i = 0; i < E->get().frames.size(); i++) + E->get().frames.write[i] = p_frames[i]; +} +Array SpriteFrames::_get_frames() const { + + return Array(); +} + +Array SpriteFrames::_get_animations() const { + + Array anims; + for (Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) { + Dictionary d; + d["name"] = E->key(); + d["speed"] = E->get().speed; + d["loop"] = E->get().loop; + Array frames; + for (int i = 0; i < E->get().frames.size(); i++) { + frames.push_back(E->get().frames[i]); + } + d["frames"] = frames; + anims.push_back(d); + } + + return anims; +} +void SpriteFrames::_set_animations(const Array &p_animations) { + + animations.clear(); + for (int i = 0; i < p_animations.size(); i++) { + + Dictionary d = p_animations[i]; + + ERR_CONTINUE(!d.has("name")); + ERR_CONTINUE(!d.has("speed")); + ERR_CONTINUE(!d.has("loop")); + ERR_CONTINUE(!d.has("frames")); + + Anim anim; + anim.speed = d["speed"]; + anim.loop = d["loop"]; + Array frames = d["frames"]; + for (int i = 0; i < frames.size(); i++) { + + RES res = frames[i]; + anim.frames.push_back(res); + } + + animations[d["name"]] = anim; + } +} + void SpriteFrames::_bind_methods() { ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation); @@ -249,6 +308,16 @@ void SpriteFrames::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_frame", "anim", "idx"), &SpriteFrames::remove_frame); ClassDB::bind_method(D_METHOD("clear", "anim"), &SpriteFrames::clear); ClassDB::bind_method(D_METHOD("clear_all"), &SpriteFrames::clear_all); + + ClassDB::bind_method(D_METHOD("_set_frames"), &SpriteFrames::_set_frames); + ClassDB::bind_method(D_METHOD("_get_frames"), &SpriteFrames::_get_frames); + + ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", 0), "_set_frames", "_get_frames"); //compatibility + + ClassDB::bind_method(D_METHOD("_set_animations"), &SpriteFrames::_set_animations); + ClassDB::bind_method(D_METHOD("_get_animations"), &SpriteFrames::_get_animations); + + ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_animations", "_get_animations"); //compatibility } SpriteFrames::SpriteFrames() { diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 672c9ef327..cc49465403 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -54,6 +54,12 @@ class SpriteFrames : public Resource { Map<StringName, Anim> animations; + Array _get_frames() const; + void _set_frames(const Array &p_frames); + + Array _get_animations() const; + void _set_animations(const Array &p_animations); + Vector<String> _get_animation_list() const; protected: diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 0eaeea9627..f56cc897ca 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4174,7 +4174,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { } } - return CURSOR_IBEAM; + return get_default_cursor_shape(); } void TextEdit::set_text(String p_text) { @@ -6256,6 +6256,7 @@ TextEdit::TextEdit() { breakpoint_gutter_width = 0; cache.fold_gutter_width = 0; fold_gutter_width = 0; + set_default_cursor_shape(CURSOR_IBEAM); indent_size = 4; text.set_indent_size(indent_size); |