Пример #1
0
        public void LoadLanguage(PackageInfo game, PackageSystem vfs, string subPath)
        {
            // load languages
            foreach (PackageInfo info in PackageInfos)
            {
                if (info.GameName == game.GameName)
                {
                    if (info.Type == PackageType.Language)
                    {
                        if (!vfs.ExistsMount(info.Package))
                        {
                            PackageFactory factory = new PackageFactory();
                            IPackage       package = factory.OpenPackage(basePath + info.Package, subPath);
                            vfs.Mount(info.Package, package);

                            ApplyPatches(info, vfs);
                        }

                        // add language codes to available language list
                        foreach (string lang in info.Languages)
                        {
                            if (!languages.Contains(lang))
                            {
                                languages.Add(lang);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        static public PackageInfo TryCreate(string inFileName, PackageSystem inVFS)
        {
            string package = System.IO.Path.GetFileName(inFileName);

            File file;

            // open file from package if available
            if (inVFS.ExistsMount(package))
            {
                file = inVFS.GetFile(package + ":info.txt", FileOpenMode.Read);
            }
            // open file without loading the package
            else
            {
                file = inVFS.GetFile(inFileName + ":info.txt", FileOpenMode.NoPackage);
            }

            if (file != null)
            {
                ConfigFile config = new ConfigFile();
                config.Open(file);

                PackageInfo info = new PackageInfo();
                info.package      = package;
                info.dependencies = config[""].GetStrings("dependencies");
                info.mainModule   = config[""].GetString("start");
                info.modules      = config[""].GetStrings("modules");
                info.languages    = config[""].GetStrings("language");
                info.version      = config[""].GetVersion("version");
                info.baseVersion  = config[""].GetVersion("base");
                switch (config[""].Get("type"))
                {
                case "patch":
                    info.type = PackageType.Patch;
                    break;

                case "game":
                    info.type = PackageType.Game;
                    break;

                case "language":
                    info.type = PackageType.Language;
                    break;

                default:
                    info.type = PackageType.Data;
                    break;
                }
                info.game   = config[""].GetString("game");
                info.hidden = config[""].GetBool("hidden");
                return(info);
            }

            return(null);
        }
Пример #3
0
        void ApplyPatches(PackageInfo package, PackageSystem vfs)
        {
            Version currentVersion = package.Version;
            Version nextVersion    = currentVersion;

            List <PackageInfo> applyList = new List <PackageInfo>();

            // search latest patch version
            PackageInfo best = null;

            do
            {
                best = null;

                foreach (PackageInfo info in PackageInfos)
                {
                    if (info.GameName == package.Package)
                    {
                        if (info.Type == PackageType.Patch)
                        {
                            if (info.BaseVersion == currentVersion && info.Version > nextVersion)
                            {
                                best        = info;
                                nextVersion = info.Version;
                            }
                        }
                    }
                }

                if (best != null)
                {
                    currentVersion = nextVersion;
                    applyList.Add(best);
                }
            } while (best != null);

            // apply patches
            foreach (PackageInfo info in applyList)
            {
                if (!vfs.ExistsMount(info.Package))
                {
                    PackageFactory factory = new PackageFactory();
                    IPackage       p       = factory.OpenPackage(basePath + info.Package);
                    vfs.Mount(info.Package, p);
                }
            }
        }
Пример #4
0
        private bool Add(string package, PackageSystem vfs, AssemblyControl assembly, bool loadExtras)
        {
            if (package.ToLower() == "burntime")
            {
                Burntime.Common.BurntimePath path = new Burntime.Common.BurntimePath(FileSystem.BasePath + "system/");
                while (!path.IsValid)
                {
                    if (!path.ShowSelector())
                    {
                        Environment.Exit(0);
                    }
                    if (path.IsValid)
                    {
                        path.Save();
                    }
                }

                string burntimePackage = path.Path;
                if (burntimePackage.EndsWith(".pak"))
                {
                    burntimePackage = burntimePackage.Substring(0, burntimePackage.Length - 4);
                }

                // make absolute path to avoid using basePath from FileSystem
                string absolutePath = burntimePackage;
                if (!System.IO.Path.IsPathRooted(absolutePath))
                {
                    absolutePath = System.IO.Path.GetFullPath(FileSystem.BasePath + "system/" + absolutePath);
                }
                IPackage burntime = FileSystem.OpenPackage(absolutePath, "BURN_GFX/");
                if (burntime == null)
                {
                    // something went wrong
                    throw new Exception("BURN_GFX folder was not found. Please make sure to set the correct path in system/path.txt to where the BURN_GFX and BURN.EXE are!");
                }

                vfs.Mount(package, burntime);
                return(true);
            }

            PackageInfo info = PackageInfo.TryCreate(basePath + package, vfs);

            if (info == null)
            {
                return(false);
            }

            if (info.Type == PackageType.Game)
            {
                Add(info.Dependencies, vfs, assembly, loadExtras);

                if (!vfs.ExistsMount(package))
                {
                    PackageFactory factory = new PackageFactory();
                    IPackage       p       = factory.OpenPackage(basePath + package);
                    vfs.Mount(package, p);
                }

                // add language codes to available language list
                foreach (string lang in info.Languages)
                {
                    if (!languages.Contains(lang))
                    {
                        languages.Add(lang);
                    }
                }

                ApplyPatches(info, vfs);

                if (loadExtras)
                {
                    LoadLanguage(info, vfs, "");
                    LoadExtras(info, vfs);
                }

                if (assembly != null)
                {
                    assembly.Load(info.Modules, package);
                }
            }

            return(true);
        }