示例#1
0
        bool TryGetFinalBinPath(IServiceProvider serviceProvider, Properties props, out string binPath)
        {
            while (true)
            {
                var useBinPath = (bool)props.Item(nameof(MDKOptions.UseManualGameBinPath)).Value;
                binPath = ((string)props.Item(nameof(MDKOptions.GameBinPath))?.Value)?.Trim() ?? "";
                if (!useBinPath || binPath == "")
                {
                    binPath = _spaceEngineers.GetInstallPath("Bin64");
                    if (binPath == null)
                    {
                        // We don't have a path. Just exit, let the dialog take care of it
                        return(true);
                    }
                }

                var binDirectory = new DirectoryInfo(binPath);
                if (!binDirectory.Exists)
                {
                    // We have a configured path, but it fails.
                    var res = VsShellUtilities.ShowMessageBox(serviceProvider, Text.IngameScriptWizard_TryGetFinalBinPath_SEBinPathNotFoundDescription, Text.IngameScriptWizard_TryGetFinalBinPath_SEBinPathNotFound, OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_RETRYCANCEL, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND);
                    if (res == 4)
                    {
                        continue;
                    }
                    binPath = null;
                    return(false);
                }
                binPath = binDirectory.ToString().TrimEnd('\\');
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// Creates an instance of <see cref="MDKOptions" />
        /// </summary>
        public MDKOptions()
        {
            _spaceEngineers = new SpaceEngineers();

            ((MDKOptionsControl)Child).Options = this;
            _gameBinPath = _spaceEngineers.GetInstallPath("Bin64");
            _outputPath  = _spaceEngineers.GetDataPath("IngameScripts", "local");
        }
示例#3
0
        public static async Task Update(string whitelistCacheFileName, string output)
        {
            var api = await LoadAsync(whitelistCacheFileName);

            var spaceEngineers  = new SpaceEngineers();
            var typeDefinitions = await TypeDefinitions.LoadAsync(spaceEngineers.GetInstallPath("Content\\Data"));

            await api.SaveAsync(typeDefinitions, output);
        }
示例#4
0
        public SpaceEngineersText()
        {
            var spaceEngineers = new SpaceEngineers();
            var document       = XDocument.Load(spaceEngineers.GetInstallPath(@"Content\Data\Localization\MyTexts.resx"));
            var stringElements = document.XPathSelectElements(@"root/data");

            foreach (var element in stringElements)
            {
                _texts[(string)element.Attribute("name")] = (string)element.Element("value");
            }
        }
示例#5
0
        public async Task Scan(string whitelistCacheFileName)
        {
            await Task.Run(() =>
            {
                var whitelist      = Whitelist.Load(whitelistCacheFileName);
                var spaceEngineers = new SpaceEngineers();
                var installPath    = Path.Combine(spaceEngineers.GetInstallPath(), "bin64");
                MDKUtilityFramework.Load(installPath);
                var dllFiles = Directory.EnumerateFiles(installPath, "*.dll", SearchOption.TopDirectoryOnly)
                               .ToList();

                foreach (var dllFile in dllFiles)
                {
                    Visit(whitelist, dllFile);
                }

                foreach (var assemblyGroup in _members.GroupBy(m => m.DeclaringType.Assembly))
                {
                    var assemblyPath = new Uri(assemblyGroup.Key.CodeBase).LocalPath;
                    var xmlFileName  = Path.ChangeExtension(assemblyPath, "xml");
                    XDocument documentation;
                    if (File.Exists(xmlFileName))
                    {
                        documentation = XDocument.Load(xmlFileName);
                    }
                    else
                    {
                        documentation = null;
                    }
                    foreach (var typeGroup in assemblyGroup.GroupBy(m => m.DeclaringType))
                    {
                        var typeEntry = ApiEntry.Create(typeGroup.Key, documentation);
                        _entries.Add(typeEntry);
                        foreach (var member in typeGroup)
                        {
                            var entry = ApiEntry.Create(member, documentation);
                            _entries.Add(entry);
                        }
                    }
                }

                foreach (var entry in _entries)
                {
                    entry.ResolveLinks(_entries);
                }
            });
        }
示例#6
0
        public static async Task <ProgrammableBlockApi> LoadAsync(string whitelistCacheFileName)
        {
            var api = new ProgrammableBlockApi();
            await Task.Run(() =>
            {
                var members        = new List <MemberInfo>();
                var spaceEngineers = new SpaceEngineers();
                var installPath    = Path.Combine(spaceEngineers.GetInstallPath(), "bin64");
                MDKUtilityFramework.Load(installPath);
                var dllFiles = Directory.EnumerateFiles(installPath, "*.dll", SearchOption.TopDirectoryOnly)
                               .ToList();
                foreach (var file in dllFiles)
                {
                    LoadAssembly(file);
                }
                //var assemblies = dllFiles.Select(LoadAssembly).Where(a => a != null).ToList();
                var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
                var whitelist  = Whitelist.Load(whitelistCacheFileName);
                api._whitelist = whitelist;

                foreach (var assembly in assemblies)
                {
                    Visit(whitelist, assembly, members);
                }

                // Hack. I'm getting duplicated entries and atm I cannot be bothered to do a proper check
                // for why...
                var visitedMembers = new HashSet <MemberInfo>();

                foreach (var assemblyGroup in members.GroupBy(m => m.GetAssembly()))
                {
                    foreach (var typeGroup in assemblyGroup.GroupBy(m => m.DeclaringType))
                    {
                        if (typeGroup.Key == null)
                        {
                            foreach (var type in typeGroup)
                            {
                                var entry = api.GetEntry(type);
                                if (!api._entries.Contains(entry))
                                {
                                    api._entries.Add(entry);
                                }
                            }

                            continue;
                        }

                        var typeEntry = api.GetEntry(typeGroup.Key);
                        if (typeEntry != null)
                        {
                            if (!visitedMembers.Add(typeEntry.Member))
                            {
                                continue;
                            }
                            if (!api._entries.Contains(typeEntry))
                            {
                                api._entries.Add(typeEntry);
                            }
                            foreach (var member in typeGroup)
                            {
                                var entry = api.GetEntry(member);
                                if (entry != null)
                                {
                                    if (!visitedMembers.Add(member))
                                    {
                                        continue;
                                    }
                                    api._entries.Add(entry);
                                }
                            }
                        }
                    }
                }

                foreach (var entry in api.Entries)
                {
                    entry.ResolveLinks();
                }
            });

            return(api);
        }