├── .gitignore ├── LICENSE ├── README.md └── mono ├── SCsub ├── config.py ├── csharp_script.cpp ├── csharp_script.h ├── doc_classes ├── @C#.xml ├── CSharpScript.xml └── GodotSharp.xml ├── editor ├── GodotSharpTools │ ├── Build │ │ └── BuildSystem.cs │ ├── Editor │ │ └── MonoDevelopInstance.cs │ ├── GodotSharpTools.csproj │ ├── GodotSharpTools.sln │ ├── Project │ │ ├── ProjectExtensions.cs │ │ ├── ProjectGenerator.cs │ │ └── ProjectUtils.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── StringExtensions.cs ├── bindings_generator.cpp ├── bindings_generator.h ├── build_process.cpp ├── build_process.h ├── csharp_project.cpp ├── csharp_project.h ├── godotsharp_builds.cpp ├── godotsharp_builds.h ├── godotsharp_editor.cpp ├── godotsharp_editor.h ├── mono_bottom_panel.cpp ├── mono_bottom_panel.h ├── mono_build_info.h ├── monodevelop_instance.cpp ├── monodevelop_instance.h ├── net_solution.cpp └── net_solution.h ├── glue ├── cs_files │ ├── Basis.cs │ ├── Color.cs │ ├── Error.cs │ ├── ExportAttribute.cs │ ├── GD.cs │ ├── GodotMethodAttribute.cs │ ├── GodotSynchronizationContext.cs │ ├── GodotTaskScheduler.cs │ ├── IAwaitable.cs │ ├── IAwaiter.cs │ ├── MarshalUtils.cs │ ├── Mathf.cs │ ├── Plane.cs │ ├── Quat.cs │ ├── RPCAttributes.cs │ ├── Rect2.cs │ ├── Rect3.cs │ ├── SignalAwaiter.cs │ ├── StringExtensions.cs │ ├── ToolAttribute.cs │ ├── Transform.cs │ ├── Transform2D.cs │ ├── Vector2.cs │ └── Vector3.cs └── glue_header.h ├── godotsharp_defs.h ├── godotsharp_dirs.cpp ├── godotsharp_dirs.h ├── il_opcode_parser.cpp ├── il_opcode_parser.h ├── mono_gc_handle.cpp ├── mono_gc_handle.h ├── mono_gd ├── gd_mono.cpp ├── gd_mono.h ├── gd_mono_assembly.cpp ├── gd_mono_assembly.h ├── gd_mono_class.cpp ├── gd_mono_class.h ├── gd_mono_field.cpp ├── gd_mono_field.h ├── gd_mono_header.h ├── gd_mono_internals.cpp ├── gd_mono_internals.h ├── gd_mono_log.cpp ├── gd_mono_log.h ├── gd_mono_marshal.cpp ├── gd_mono_marshal.h ├── gd_mono_method.cpp ├── gd_mono_method.h ├── gd_mono_utils.cpp └── gd_mono_utils.h ├── mono_reg_utils.py ├── register_types.cpp ├── register_types.h ├── signal_awaiter_utils.cpp ├── signal_awaiter_utils.h └── utils ├── mono_reg_utils.cpp ├── mono_reg_utils.h ├── path_utils.cpp ├── path_utils.h ├── string_utils.cpp └── string_utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Module generated files 2 | 3 | *.gen.* 4 | 5 | # Python 6 | 7 | *.pyc 8 | 9 | # C++ 10 | 11 | # Compiled Object files 12 | *.slo 13 | *.lo 14 | *.o 15 | *.obj 16 | 17 | # Precompiled Headers 18 | *.gch 19 | *.pch 20 | 21 | # Compiled Dynamic libraries 22 | *.so 23 | *.dylib 24 | *.dll 25 | 26 | # Fortran module files 27 | *.mod 28 | *.smod 29 | 30 | # Compiled Static libraries 31 | *.lai 32 | *.la 33 | *.a 34 | *.lib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | 41 | 42 | # C# 43 | 44 | # User-specific files 45 | *.suo 46 | *.user* 47 | *.sln.docstates 48 | 49 | # Build results 50 | 51 | [Dd]ebug/ 52 | [Rr]elease/ 53 | x64/ 54 | build/ 55 | [Bb]in/ 56 | [Oo]bj/ 57 | 58 | # MSTest test Results 59 | [Tt]est[Rr]esult*/ 60 | [Bb]uild[Ll]og.* 61 | 62 | *_i.c 63 | *_p.c 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.pch 68 | *.pdb 69 | *.pgc 70 | *.pgd 71 | *.rsp 72 | *.sbr 73 | *.tlb 74 | *.tli 75 | *.tlh 76 | *.tmp 77 | *.tmp_proj 78 | *.log 79 | *.vspscc 80 | *.vssscc 81 | .builds 82 | *.pidb 83 | *.log 84 | *.scc 85 | 86 | # OS generated files # 87 | .DS_Store* 88 | Icon? 89 | 90 | # Visual C++ cache files 91 | ipch/ 92 | *.aps 93 | *.ncb 94 | *.opensdf 95 | *.sdf 96 | *.cachefile 97 | 98 | # Visual Studio profiler 99 | *.psess 100 | *.vsp 101 | *.vspx 102 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ignacio Etcheverry 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **THIS REPOSITORY IS OUTDATED. DEVELOPMENT MOVED TO THE GODOT OFFICIAL REPOSITORY** 2 | -------------------------------------------------------------------------------- /mono/SCsub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | Import('env') 4 | 5 | 6 | def make_cs_files_header(src, dst): 7 | with open(dst, 'wb') as header: 8 | header.write('/* This is an automatically generated file; DO NOT EDIT! OK THX */\n') 9 | header.write('#ifndef _CS_FILES_DATA_H\n') 10 | header.write('#define _CS_FILES_DATA_H\n\n') 11 | header.write('#include "map.h"\n') 12 | header.write('#include "ustring.h"\n') 13 | inserted_files = '' 14 | import os 15 | for file in os.listdir(src): 16 | if file.endswith('.cs'): 17 | with open(os.path.join(src, file), 'rb') as f: 18 | buf = f.read() 19 | decomp_size = len(buf) 20 | import zlib 21 | buf = zlib.compress(buf) 22 | name = os.path.splitext(file)[0] 23 | header.write('\nstatic const int _cs_' + name + '_compressed_size = ' + str(len(buf)) + ';\n') 24 | header.write('static const int _cs_' + name + '_uncompressed_size = ' + str(decomp_size) + ';\n') 25 | header.write('static const unsigned char _cs_' + name + '_compressed[] = { ') 26 | for i, buf_idx in enumerate(range(len(buf))): 27 | if i > 0: 28 | header.write(', ') 29 | header.write(str(ord(buf[buf_idx]))) 30 | inserted_files += '\tr_files.insert(\"' + file + '\", ' \ 31 | 'CompressedFile(_cs_' + name + '_compressed_size, ' \ 32 | '_cs_' + name + '_uncompressed_size, ' \ 33 | '_cs_' + name + '_compressed));\n' 34 | header.write(' };\n') 35 | header.write('\nstruct CompressedFile\n' '{\n' 36 | '\tint compressed_size;\n' '\tint uncompressed_size;\n' '\tconst unsigned char* data;\n' 37 | '\n\tCompressedFile(int p_comp_size, int p_uncomp_size, const unsigned char* p_data)\n' 38 | '\t{\n' '\t\tcompressed_size = p_comp_size;\n' '\t\tuncompressed_size = p_uncomp_size;\n' 39 | '\t\tdata = p_data;\n' '\t}\n' '\n\tCompressedFile() {}\n' '};\n' 40 | '\nvoid get_compressed_files(Map& r_files)\n' '{\n' + inserted_files + '}\n' 41 | ) 42 | header.write('#endif // _CS_FILES_DATA_H') 43 | 44 | 45 | env.add_source_files(env.modules_sources, '*.cpp') 46 | env.add_source_files(env.modules_sources, 'mono_gd/*.cpp') 47 | env.add_source_files(env.modules_sources, 'utils/*.cpp') 48 | 49 | if env['tools']: 50 | env.add_source_files(env.modules_sources, 'editor/*.cpp') 51 | make_cs_files_header('glue/cs_files', 'glue/cs_compressed.gen.h') 52 | 53 | vars = Variables() 54 | vars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True)) 55 | vars.Update(env) 56 | 57 | # Glue sources 58 | if env['mono_glue']: 59 | env.add_source_files(env.modules_sources, 'glue/*.cpp') 60 | else: 61 | env.Append(CPPDEFINES = [ 'MONO_GLUE_DISABLED' ]) 62 | 63 | if ARGUMENTS.get('yolo_copy', False): 64 | env.Append(CPPDEFINES = [ 'YOLO_COPY' ]) 65 | 66 | # Build GodotSharpTools solution 67 | 68 | import os 69 | import subprocess 70 | import mono_reg_utils as monoreg 71 | 72 | 73 | def mono_build_solution(source, target, env): 74 | if os.name == 'nt': 75 | msbuild_tools_path = monoreg.find_msbuild_tools_path_reg() 76 | if not msbuild_tools_path: 77 | raise RuntimeError('Cannot find MSBuild Tools Path in the registry') 78 | msbuild_path = os.path.join(msbuild_tools_path, 'MSBuild.exe') 79 | else: 80 | msbuild_path = 'msbuild' 81 | 82 | output_path = os.path.abspath(os.path.join(str(target[0]), os.pardir)) 83 | 84 | msbuild_args = [ 85 | msbuild_path, 86 | os.path.abspath(str(source[0])), 87 | '/p:Configuration=Release', 88 | '/p:OutputPath=' + output_path 89 | ] 90 | 91 | msbuild_env = os.environ.copy() 92 | 93 | # Needed when running from Developer Command Prompt for VS 94 | if 'PLATFORM' in msbuild_env: 95 | del msbuild_env['PLATFORM'] 96 | 97 | msbuild_alt_paths = [ 'xbuild' ] 98 | 99 | while True: 100 | try: 101 | subprocess.check_call(msbuild_args, env = msbuild_env) 102 | break 103 | except subprocess.CalledProcessError: 104 | raise RuntimeError('GodotSharpTools build failed') 105 | except OSError: 106 | if os.name is not 'nt': 107 | if not msbuild_alt_paths: 108 | raise RuntimeError('Could not find commands msbuild or xbuild') 109 | # Try xbuild 110 | msbuild_args[0] = msbuild_alt_paths.pop(0) 111 | else: 112 | raise RuntimeError('Could not find command MSBuild.exe') 113 | 114 | 115 | mono_sln_builder = Builder(action = mono_build_solution) 116 | env.Append(BUILDERS = { 'MonoBuildSolution' : mono_sln_builder }) 117 | env.MonoBuildSolution( 118 | os.path.join(Dir('#bin').abspath, 'GodotSharpTools.dll'), 119 | 'editor/GodotSharpTools/GodotSharpTools.sln' 120 | ) 121 | -------------------------------------------------------------------------------- /mono/config.py: -------------------------------------------------------------------------------- 1 | 2 | import imp 3 | import os 4 | import subprocess 5 | import sys 6 | 7 | from SCons.Script import BoolVariable, Environment, Variables 8 | from shutil import copyfile 9 | 10 | monoreg = imp.load_source('mono_reg_utils', 'modules/mono/mono_reg_utils.py') 11 | 12 | 13 | def find_file_in_dir(dir, files, prefix = '', extension = ''): 14 | if not extension.startswith('.'): 15 | extension = '.' + extension 16 | for file in files: 17 | if os.path.isfile(os.path.join(dir, prefix + file + extension)): 18 | return file 19 | 20 | return None 21 | 22 | 23 | def can_build(platform): 24 | return True 25 | 26 | 27 | def configure(env): 28 | env.use_ptrcall = True 29 | 30 | vars = Variables() 31 | vars.Add(BoolVariable('mono_static', 'Statically link mono', False)) 32 | vars.Update(env) 33 | 34 | mono_static = env['mono_static'] 35 | 36 | mono_lib_names = [ 'mono-2.0-sgen', 'monosgen-2.0' ] 37 | 38 | if env['platform'] == 'windows': 39 | if mono_static: 40 | raise RuntimeError('mono-static: Not supported on Windows') 41 | 42 | if env['bits'] == '32': 43 | if os.getenv('MONO32_PREFIX'): 44 | mono_root = os.getenv('MONO32_PREFIX') 45 | else: 46 | mono_root = monoreg.find_mono_root_dir() 47 | else: 48 | if os.getenv('MONO64_PREFIX'): 49 | mono_root = os.getenv('MONO64_PREFIX') 50 | else: 51 | mono_root = monoreg.find_mono_root_dir() 52 | 53 | if mono_root is None: 54 | raise RuntimeError('Mono installation directory not found') 55 | 56 | mono_lib_path = os.path.join(mono_root, 'lib') 57 | 58 | env.Append(LIBPATH = mono_lib_path) 59 | env.Append(CPPPATH = os.path.join(mono_root, 'include', 'mono-2.0')) 60 | 61 | mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension = '.lib') 62 | 63 | if not mono_lib_name: 64 | raise RuntimeError('Could not find mono library in: ' + mono_lib_path) 65 | 66 | if os.getenv('VCINSTALLDIR'): 67 | env.Append(LINKFLAGS = mono_lib_name + Environment()['LIBSUFFIX']) 68 | else: 69 | env.Append(LIBS = mono_lib_name ) 70 | 71 | mono_bin_path = os.path.join(mono_root, 'bin') 72 | 73 | mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension = '.dll') 74 | 75 | mono_dll_src = os.path.join(mono_bin_path, mono_dll_name + '.dll') 76 | mono_dll_dst = os.path.join('bin', mono_dll_name + '.dll') 77 | copy_mono_dll = True 78 | 79 | if not os.path.isdir('bin'): 80 | os.mkdir('bin') 81 | elif os.path.exists(mono_dll_dst): 82 | copy_mono_dll = False 83 | 84 | if copy_mono_dll: 85 | copyfile(mono_dll_src, mono_dll_dst) 86 | else: 87 | mono_root = None 88 | 89 | if env['bits'] == '32': 90 | if os.getenv('MONO32_PREFIX'): 91 | mono_root = os.getenv('MONO32_PREFIX') 92 | else: 93 | if os.getenv('MONO64_PREFIX'): 94 | mono_root = os.getenv('MONO64_PREFIX') 95 | 96 | if mono_root: 97 | mono_lib_path = os.path.join(mono_root, 'lib') 98 | 99 | env.Append(LIBPATH = mono_lib_path) 100 | env.Append(CPPPATH = os.path.join(mono_root, 'include', 'mono-2.0')) 101 | 102 | mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix = 'lib', extension = '.a') 103 | 104 | if not mono_lib: 105 | raise RuntimeError('Could not find mono library in: ' + mono_lib_path) 106 | 107 | env.Append(CPPFLAGS = [ '-D_REENTRANT' ]) 108 | 109 | if mono_static: 110 | mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') 111 | 112 | if sys.platform == "darwin": 113 | env.Append(LINKFLAGS = [ '-Wl,-force_load,' + mono_lib_file ]) 114 | elif sys.platform == "linux" or sys.platform == "linux2": 115 | env.Append(LINKFLAGS = [ '-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive' ]) 116 | else: 117 | raise RuntimeError('mono-static: Not supported on this platform') 118 | else: 119 | env.Append(LIBS = [ mono_lib ] ) 120 | 121 | env.Append(LIBS = [ 'm', 'rt', 'dl', 'pthread' ] ) 122 | else: 123 | if mono_static: 124 | raise RuntimeError('mono-static: Not supported with pkg-config. Specify a mono prefix manually') 125 | 126 | env.ParseConfig('pkg-config mono-2 --cflags --libs') 127 | 128 | env.Append(LINKFLAGS = '-rdynamic') 129 | 130 | 131 | def get_doc_classes(): 132 | return [ "@C#", "CSharpScript", "GodotSharp" ] 133 | 134 | 135 | def get_doc_path(): 136 | return "doc_classes" 137 | 138 | -------------------------------------------------------------------------------- /mono/doc_classes/@C#.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /mono/doc_classes/CSharpScript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono/doc_classes/GodotSharp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Attaches the current thread to the mono runtime. 17 | 18 | 19 | 20 | 21 | 22 | 23 | Detaches the current thread from the mono runtime. 24 | 25 | 26 | 27 | 28 | 29 | 30 | Returns whether the scripts domain is loaded. 31 | 32 | 33 | 34 | 35 | 36 | 37 | Returns whether the scripts domain is being finalized. 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/Editor/MonoDevelopInstance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | 6 | namespace GodotSharpTools.Editor 7 | { 8 | public class MonoDevelopInstance 9 | { 10 | private Process process; 11 | private string solutionFile; 12 | 13 | public void Execute(string[] files) 14 | { 15 | bool newWindow = process == null || process.HasExited; 16 | 17 | List args = new List(); 18 | 19 | args.Add("--ipc-tcp"); 20 | 21 | if (newWindow) 22 | args.Add("\"" + Path.GetFullPath(solutionFile) + "\""); 23 | 24 | foreach (var file in files) 25 | { 26 | int semicolonIndex = file.IndexOf(';'); 27 | 28 | string filePath = semicolonIndex < 0 ? file : file.Substring(0, semicolonIndex); 29 | string cursor = semicolonIndex < 0 ? string.Empty : file.Substring(semicolonIndex); 30 | 31 | args.Add("\"" + Path.GetFullPath(filePath.NormalizePath()) + cursor + "\""); 32 | } 33 | 34 | if (newWindow) 35 | { 36 | ProcessStartInfo startInfo = new ProcessStartInfo(MonoDevelopFile, string.Join(" ", args)); 37 | process = Process.Start(startInfo); 38 | } 39 | else 40 | { 41 | Process.Start(MonoDevelopFile, string.Join(" ", args)); 42 | } 43 | } 44 | 45 | public MonoDevelopInstance(string solutionFile) 46 | { 47 | this.solutionFile = solutionFile; 48 | } 49 | 50 | private static string MonoDevelopFile 51 | { 52 | get 53 | { 54 | return "monodevelop"; 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/GodotSharpTools.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984} 7 | Library 8 | GodotSharpTools 9 | GodotSharpTools 10 | v4.5 11 | 12 | 13 | true 14 | full 15 | false 16 | bin\Debug 17 | DEBUG; 18 | prompt 19 | 4 20 | false 21 | 22 | 23 | full 24 | true 25 | bin\Release 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/GodotSharpTools.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotSharpTools", "GodotSharpTools.csproj", "{A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | EndGlobal 18 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/Project/ProjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Build.Construction; 3 | 4 | namespace GodotSharpTools.Project 5 | { 6 | public static class ProjectExtensions 7 | { 8 | public static bool HasItem(this ProjectRootElement root, string itemType, string include) 9 | { 10 | string includeNormalized = include.NormalizePath(); 11 | 12 | foreach (var itemGroup in root.ItemGroups) 13 | { 14 | if (itemGroup.Condition.Length != 0) 15 | continue; 16 | 17 | foreach (var item in itemGroup.Items) 18 | { 19 | if (item.ItemType == itemType) 20 | { 21 | if (item.Include.NormalizePath() == includeNormalized) 22 | return true; 23 | } 24 | } 25 | } 26 | 27 | return false; 28 | } 29 | 30 | public static void AddItemChecked(this ProjectRootElement root, string itemType, string include) 31 | { 32 | if (!root.HasItem(itemType, include)) 33 | { 34 | root.AddItem(itemType, include); 35 | } 36 | } 37 | 38 | public static Guid GetGuid(this ProjectRootElement root) 39 | { 40 | foreach (var property in root.Properties) 41 | { 42 | if (property.Name == "ProjectGuid") 43 | return Guid.Parse(property.Value); 44 | } 45 | 46 | return Guid.Empty; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/Project/ProjectUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Microsoft.Build.Construction; 4 | 5 | namespace GodotSharpTools.Project 6 | { 7 | public static class ProjectUtils 8 | { 9 | public static void AddItemToProjectChecked(string projectPath, string itemType, string include) 10 | { 11 | var dir = Directory.GetParent(projectPath).FullName; 12 | var root = ProjectRootElement.Open(projectPath); 13 | root.AddItemChecked(itemType, include.RelativeToPath(dir).Replace("/", "\\")); 14 | root.Save(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("GodotSharpTools")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("")] 12 | [assembly: AssemblyCopyright("ignacio")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /mono/editor/GodotSharpTools/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace GodotSharpTools 5 | { 6 | public static class StringExtensions 7 | { 8 | public static string RelativeToPath(this string path, string dir) 9 | { 10 | // Make sure the directory ends with a path separator 11 | dir = Path.Combine(dir, " ").TrimEnd(); 12 | 13 | if (Path.DirectorySeparatorChar == '\\') 14 | dir = dir.Replace("/", "\\") + "\\"; 15 | 16 | Uri fullPath = new Uri(Path.GetFullPath(path), UriKind.Absolute); 17 | Uri relRoot = new Uri(Path.GetFullPath(dir), UriKind.Absolute); 18 | 19 | return relRoot.MakeRelativeUri(fullPath).ToString(); 20 | } 21 | 22 | public static string NormalizePath(this string path) 23 | { 24 | bool rooted = path.IsAbsolutePath(); 25 | 26 | path = path.Replace('\\', '/'); 27 | 28 | string[] parts = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 29 | 30 | path = string.Join(Path.DirectorySeparatorChar.ToString(), parts).Trim(); 31 | 32 | return rooted ? Path.DirectorySeparatorChar.ToString() + path : path; 33 | } 34 | 35 | private static readonly string driveRoot = Path.GetPathRoot(Environment.CurrentDirectory); 36 | 37 | public static bool IsAbsolutePath(this string path) 38 | { 39 | return path.StartsWith("/") || path.StartsWith("\\") || path.StartsWith(driveRoot); 40 | } 41 | 42 | public static string CsvEscape(this string value, char delimiter = ',') 43 | { 44 | bool hasSpecialChar = value.IndexOfAny(new char[] { '\"', '\n', '\r', delimiter }) != -1; 45 | 46 | if (hasSpecialChar) 47 | return "\"" + value.Replace("\"", "\"\"") + "\""; 48 | 49 | return value; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mono/editor/build_process.cpp: -------------------------------------------------------------------------------- 1 | #include "build_process.h" 2 | #if 0 3 | #include "tools/editor/editor_node.h" 4 | 5 | #include "../csharp_script.h" 6 | #include "../utils/path_utils.h" 7 | 8 | namespace MonoBuild 9 | { 10 | 11 | namespace 12 | { 13 | 14 | .... 15 | 16 | Vector EditorExportMono::custom_export(String &p_path, const Ref &p_platform) 17 | { 18 | List script_extensions; 19 | CSharpLanguage::get_singleton()->get_recognized_extensions(&script_extensions); 20 | 21 | String file_extension = p_path.extension(); 22 | 23 | if (script_extensions.find(file_extension)) { 24 | // We can't avoid to export the file because the script API needs it at runtime 25 | // But we can replace it with an empty file (well.. kind of empty) 26 | Vector placeholder; 27 | placeholder.push_back(0); // yeah, not completely empty. custom_export must return a non-empty file otherwise it has no effect 28 | return placeholder; 29 | } else if (file_extension == "dll") { 30 | BuildConfig build_config = p_platform->is_debugging_enabled() ? BuildConfig::DEBUG : BuildConfig::RELEASE; 31 | 32 | if (p_path == get_assemblies_path(build_config)) { 33 | Error err = MonoBuild::build(build_config); 34 | ERR_FAIL_COND_V(err != OK, Vector()); 35 | 36 | FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); 37 | ERR_FAIL_COND_V(!f, Vector()); 38 | Vector ret; 39 | ret.resize(f->get_len()); 40 | int rbs = f->get_buffer(ret.ptr(), ret.size()); 41 | ERR_FAIL_COND_V(rbs != ret.size(), Vector()); 42 | 43 | return ret; 44 | } 45 | } 46 | 47 | return Vector(); 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /mono/editor/build_process.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILD_PROCESS_H 2 | #define BUILD_PROCESS_H 3 | #if 0 4 | #include "editor/editor_import_export.h" 5 | 6 | #include "../build_config.h" 7 | 8 | void mono_build_callback(); 9 | 10 | namespace MonoBuild 11 | { 12 | 13 | Error build(BuildConfig build_config, bool bg = false); 14 | 15 | } 16 | 17 | class EditorExportMono : public EditorExportPlugin 18 | { 19 | OBJ_TYPE(EditorExportMono, EditorExportPlugin); 20 | 21 | public: 22 | Vector custom_export(String &p_path, const Ref &p_platform); 23 | 24 | EditorExportMono(); 25 | }; 26 | #endif 27 | #endif // BUILD_PROCESS_H 28 | -------------------------------------------------------------------------------- /mono/editor/csharp_project.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* csharp_project.cpp */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* https://godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ 9 | /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ 10 | /* */ 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ 12 | /* a copy of this software and associated documentation files (the */ 13 | /* "Software"), to deal in the Software without restriction, including */ 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 | /* permit persons to whom the Software is furnished to do so, subject to */ 17 | /* the following conditions: */ 18 | /* */ 19 | /* The above copyright notice and this permission notice shall be */ 20 | /* included in all copies or substantial portions of the Software. */ 21 | /* */ 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 | /*************************************************************************/ 30 | #include "csharp_project.h" 31 | 32 | #include "os/os.h" 33 | #include "project_settings.h" 34 | 35 | #include "../mono_gd/gd_mono_class.h" 36 | #include "../mono_gd/gd_mono_marshal.h" 37 | 38 | namespace CSharpProject { 39 | 40 | String generate_core_api_project(const String &p_dir, const Vector &p_files) { 41 | 42 | _GDMONO_SCOPE_DOMAIN_(TOOLS_DOMAIN) 43 | 44 | GDMonoClass *klass = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Project", "ProjectGenerator"); 45 | 46 | Variant dir = p_dir; 47 | Variant compile_items = p_files; 48 | const Variant *args[2] = { &dir, &compile_items }; 49 | MonoObject *ex = NULL; 50 | MonoObject *ret = klass->get_method("GenCoreApiProject", 2)->invoke(NULL, args, &ex); 51 | 52 | if (ex) { 53 | mono_print_unhandled_exception(ex); 54 | ERR_FAIL_V(String()); 55 | } 56 | 57 | return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; 58 | } 59 | 60 | String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector &p_files) { 61 | 62 | _GDMONO_SCOPE_DOMAIN_(TOOLS_DOMAIN) 63 | 64 | GDMonoClass *klass = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Project", "ProjectGenerator"); 65 | 66 | Variant dir = p_dir; 67 | Variant core_dll_path = p_core_dll_path; 68 | Variant compile_items = p_files; 69 | const Variant *args[3] = { &dir, &core_dll_path, &compile_items }; 70 | MonoObject *ex = NULL; 71 | MonoObject *ret = klass->get_method("GenEditorApiProject", 3)->invoke(NULL, args, &ex); 72 | 73 | if (ex) { 74 | mono_print_unhandled_exception(ex); 75 | ERR_FAIL_V(String()); 76 | } 77 | 78 | return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; 79 | } 80 | 81 | String generate_game_project(const String &p_dir, const String &p_name, const Vector &p_files) { 82 | 83 | _GDMONO_SCOPE_DOMAIN_(TOOLS_DOMAIN) 84 | 85 | GDMonoClass *klass = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Project", "ProjectGenerator"); 86 | 87 | Variant dir = p_dir; 88 | Variant name = p_name; 89 | Variant compile_items = p_files; 90 | const Variant *args[3] = { &dir, &name, &compile_items }; 91 | MonoObject *ex = NULL; 92 | MonoObject *ret = klass->get_method("GenGameProject", 3)->invoke(NULL, args, &ex); 93 | 94 | if (ex) { 95 | mono_print_unhandled_exception(ex); 96 | ERR_FAIL_V(String()); 97 | } 98 | 99 | return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; 100 | } 101 | 102 | void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) { 103 | 104 | _GDMONO_SCOPE_DOMAIN_(TOOLS_DOMAIN) 105 | 106 | GDMonoClass *klass = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Project", "ProjectUtils"); 107 | 108 | Variant project_path = p_project_path; 109 | Variant item_type = p_item_type; 110 | Variant include = p_include; 111 | const Variant *args[3] = { &project_path, &item_type, &include }; 112 | MonoObject *ex = NULL; 113 | klass->get_method("AddItemToProjectChecked", 3)->invoke(NULL, args, &ex); 114 | 115 | if (ex) { 116 | mono_print_unhandled_exception(ex); 117 | ERR_FAIL(); 118 | } 119 | } 120 | } // CSharpProject 121 | -------------------------------------------------------------------------------- /mono/editor/csharp_project.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* csharp_project.h */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* https://godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ 9 | /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ 10 | /* */ 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ 12 | /* a copy of this software and associated documentation files (the */ 13 | /* "Software"), to deal in the Software without restriction, including */ 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 | /* permit persons to whom the Software is furnished to do so, subject to */ 17 | /* the following conditions: */ 18 | /* */ 19 | /* The above copyright notice and this permission notice shall be */ 20 | /* included in all copies or substantial portions of the Software. */ 21 | /* */ 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 | /*************************************************************************/ 30 | #ifndef CSHARP_PROJECT_H 31 | #define CSHARP_PROJECT_H 32 | 33 | #include "ustring.h" 34 | 35 | namespace CSharpProject { 36 | 37 | String generate_core_api_project(const String &p_dir, const Vector &p_files = Vector()); 38 | String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector &p_files = Vector()); 39 | String generate_game_project(const String &p_dir, const String &p_name, const Vector &p_files = Vector()); 40 | 41 | void add_item(const String &p_project_path, const String &p_item_type, const String &p_include); 42 | } 43 | 44 | #endif // CSHARP_PROJECT_H 45 | -------------------------------------------------------------------------------- /mono/editor/godotsharp_builds.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* godotsharp_builds.h */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* https://godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ 9 | /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ 10 | /* */ 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ 12 | /* a copy of this software and associated documentation files (the */ 13 | /* "Software"), to deal in the Software without restriction, including */ 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 | /* permit persons to whom the Software is furnished to do so, subject to */ 17 | /* the following conditions: */ 18 | /* */ 19 | /* The above copyright notice and this permission notice shall be */ 20 | /* included in all copies or substantial portions of the Software. */ 21 | /* */ 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 | /*************************************************************************/ 30 | #ifndef GODOTSHARP_BUILDS_H 31 | #define GODOTSHARP_BUILDS_H 32 | 33 | #include "mono_bottom_panel.h" 34 | #include "mono_build_info.h" 35 | 36 | typedef void (*GodotSharpBuild_ExitCallback)(int); 37 | 38 | class GodotSharpBuilds { 39 | 40 | private: 41 | struct BuildProcess { 42 | Ref build_instance; 43 | MonoBuildInfo build_info; 44 | MonoBuildTab *build_tab; 45 | GodotSharpBuild_ExitCallback exit_callback; 46 | bool exited; 47 | int exit_code; 48 | 49 | void on_exit(int p_exit_code); 50 | void start(bool p_blocking = false); 51 | 52 | BuildProcess() {} 53 | BuildProcess(const MonoBuildInfo &p_build_info, GodotSharpBuild_ExitCallback p_callback = NULL); 54 | }; 55 | 56 | HashMap builds; 57 | 58 | static GodotSharpBuilds *singleton; 59 | 60 | friend class GDMono; 61 | static void _register_internal_calls(); 62 | 63 | public: 64 | enum APIType { 65 | API_CORE, 66 | API_EDITOR 67 | }; 68 | 69 | enum BuildTool { 70 | MSBUILD, 71 | MSBUILD_MONO, 72 | XBUILD 73 | }; 74 | 75 | _FORCE_INLINE_ static GodotSharpBuilds *get_singleton() { return singleton; } 76 | 77 | static void show_build_error_dialog(const String &p_message); 78 | 79 | void build_exit_callback(const MonoBuildInfo &p_build_info, int p_exit_code); 80 | 81 | void restart_build(MonoBuildTab *p_build_tab); 82 | void stop_build(MonoBuildTab *p_build_tab); 83 | 84 | bool build(const MonoBuildInfo &p_build_info); 85 | bool build_async(const MonoBuildInfo &p_build_info, GodotSharpBuild_ExitCallback p_callback = NULL); 86 | 87 | static bool build_api_sln(const String &p_name, const String &p_api_sln_dir, const String &p_config); 88 | static bool copy_api_assembly(const String &p_src_dir, const String &p_dst_dir, const String &p_assembly_name); 89 | 90 | static bool make_api_sln(APIType p_api_type); 91 | 92 | GodotSharpBuilds(); 93 | ~GodotSharpBuilds(); 94 | }; 95 | 96 | #endif // GODOTSHARP_BUILDS_H 97 | -------------------------------------------------------------------------------- /mono/editor/godotsharp_editor.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /* godotsharp_editor.h */ 3 | /*************************************************************************/ 4 | /* This file is part of: */ 5 | /* GODOT ENGINE */ 6 | /* https://godotengine.org */ 7 | /*************************************************************************/ 8 | /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ 9 | /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ 10 | /* */ 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ 12 | /* a copy of this software and associated documentation files (the */ 13 | /* "Software"), to deal in the Software without restriction, including */ 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 | /* permit persons to whom the Software is furnished to do so, subject to */ 17 | /* the following conditions: */ 18 | /* */ 19 | /* The above copyright notice and this permission notice shall be */ 20 | /* included in all copies or substantial portions of the Software. */ 21 | /* */ 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 | /*************************************************************************/ 30 | #ifndef GODOTSHARP_EDITOR_H 31 | #define GODOTSHARP_EDITOR_H 32 | 33 | #include "godotsharp_builds.h" 34 | 35 | #include "monodevelop_instance.h" 36 | 37 | class GodotSharpEditor : public Node { 38 | GDCLASS(GodotSharpEditor, Object) 39 | 40 | EditorNode *editor; 41 | 42 | MenuButton *menu_button; 43 | PopupMenu *menu_popup; 44 | 45 | AcceptDialog *error_dialog; 46 | 47 | ToolButton *bottom_panel_btn; 48 | 49 | GodotSharpBuilds *godotsharp_builds; 50 | 51 | MonoDevelopInstance *monodevel_instance; 52 | 53 | bool _create_project_solution(); 54 | 55 | void _remove_create_sln_menu_option(); 56 | 57 | void _menu_option_pressed(int p_id); 58 | 59 | static GodotSharpEditor *singleton; 60 | 61 | protected: 62 | static void _bind_methods(); 63 | 64 | public: 65 | enum MenuOptions { 66 | MENU_CREATE_SLN 67 | }; 68 | 69 | enum ExternalEditor { 70 | EDITOR_NONE, 71 | EDITOR_MONODEVELOP, 72 | EDITOR_VISUAL_STUDIO, 73 | EDITOR_CODE, 74 | }; 75 | 76 | _FORCE_INLINE_ static GodotSharpEditor *get_singleton() { return singleton; } 77 | 78 | void show_error_dialog(const String &p_message, const String &p_title = "Error"); 79 | 80 | Error open_in_external_editor(const Ref