public UnrealEngineInstance(UnrealItemDescription unrealItem)
    {
        BuildType = UnrealEngineBuildType.Source;

        unrealItem = UnrealItemDescription.RequireUnrealItem(unrealItem.RootPath, UnrealItemType.Project, UnrealItemType.Engine);

        if (unrealItem.Type == UnrealItemType.Project)
        {
            var availableBuilds = FindAvailableBuilds();
            var Configuration   = unrealItem.SanitizeConfiguration(unrealItem.ReadConfiguration <ProjectConfiguration>());
            if (!(Configuration?.UE4RootPath).IsNullOrWhiteSpace())
            {
                RootPath = Configuration.UE4RootPath;
                Uuid     = "<Engine Not Registered>";

                foreach (var(uuid, path) in availableBuilds)
                {
                    if (Path.GetFullPath(path.Item1) == RootPath)
                    {
                        Uuid      = uuid;
                        BuildType = path.Item2;
                        break;
                    }
                }
            }
            else
            {
                UProject project = UProject.Load(unrealItem.FullPath);

                if (!availableBuilds.TryGetValue(project.EngineAssociation, out var item))
                {
                    throw new UEIdNotFound(project.EngineAssociation);
                }

                Uuid      = project.EngineAssociation;
                RootPath  = Path.GetFullPath(item.Item1);
                BuildType = item.Item2;
            }
        }
        else if (unrealItem.Type == UnrealItemType.Engine)
        {
            RootPath = Path.GetFullPath(unrealItem.RootPath);

            var availableBuilds = FindAvailableBuilds();
            foreach (var pair in availableBuilds)
            {
                if (RootPath.StartsWith(Path.GetFullPath(pair.Value.Item1)))
                {
                    RootPath  = pair.Value.Item1;
                    BuildType = pair.Value.Item2;
                    Uuid      = pair.Key;

                    break;
                }
            }
        }

        Version = JsonConvert.DeserializeObject <Version>(
            File.ReadAllText(Path.Combine(BuildPath, "Build.version")));
    }
Пример #2
0
    public UnrealItemPath(UnrealItemDescription module, string path)
    {
        isFile = File.Exists(path);

        if (!path.StartsWith(module.RootPath))
        {
            Type = UnrealItemPathType.Unknow;
        }

        string localPath = path.Substring(module.RootPath.Length);

        Module = module;

        var localPathTokens = localPath.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

        LocalPath = Path.Combine(localPathTokens);
        FullPath  = Path.Combine(module.RootPath, LocalPath);
        if (localPathTokens.Length > 0)
        {
            if (localPathTokens[0].ToLower() == "private")
            {
                Type     = UnrealItemPathType.Private;
                ItemPath = Path.Combine(localPathTokens.Skip(1));
            }
            else if (localPathTokens[0].ToLower() == "public")
            {
                Type     = UnrealItemPathType.Public;
                ItemPath = Path.Combine(localPathTokens.Skip(1));
            }
            else if (localPathTokens[0].ToLower() == "classes")
            {
                Type     = UnrealItemPathType.Classes;
                ItemPath = Path.Combine(localPathTokens.Skip(1));
            }
            else
            {
                Type     = UnrealItemPathType.Common;
                ItemPath = Path.Combine(localPathTokens);
            }
        }
        else
        {
            Type     = UnrealItemPathType.Common;
            ItemPath = string.Empty;
        }
    }
Пример #3
0
    public static JsonIndentation ReadFromSettings(string path)
    {
        var uid = UnrealItemDescription.DetectUnrealItem(path, UnrealItemType.Project);

        return(uid?.ReadConfiguration <ProjectConfiguration>()?.JsonIndentation ?? Default);
    }