示例#1
0
        public FreelancerIni(string path, FileSystem vfs)
        {
            EquipmentPaths = new List <string> ();
            LoadoutPaths   = new List <string> ();
            ShiparchPaths  = new List <string> ();
            SoundPaths     = new List <string>();
            GraphPaths     = new List <string>();
            EffectPaths    = new List <string>();
            AsteroidPaths  = new List <string> ();
            RichFontPaths  = new List <string>();
            FontPaths      = new List <string>();
            PetalDbPaths   = new List <string>();
            StartupMovies  = new List <string>();
            GoodsPaths     = new List <string>();
            MarketsPaths   = new List <string>();
            FusePaths      = new List <string>();
            NewCharDBPaths = new List <string>();
            VoicePaths     = new List <string>();
            bool extNoNavmaps = false;
            bool extHideFac   = false;

            NoNavmapSystems = new List <string>(NoNavmaps);
            HiddenFactions  = new List <string>(NoShowFactions);

            //For DLL resolving (skip VFS for editor usage)
            var fullPath  = vfs == null ? path : vfs.Resolve(path);
            var directory = Path.GetDirectoryName(fullPath);
            var dirFiles  = Directory.GetFiles(directory).Select(a => Path.GetFileName(a));
            Func <string, string> resolveFileEXE = (x) =>
            {
                if (File.Exists(Path.Combine(directory, x)))
                {
                    return(Path.Combine(directory, x));
                }
                var res = dirFiles.FirstOrDefault(y => y.Equals(x, StringComparison.OrdinalIgnoreCase));
                if (res != null)
                {
                    return(Path.Combine(directory, res));
                }
                return(null);
            };

            foreach (Section s in ParseFile(fullPath, vfs))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "freelancer":
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() == "data path")
                        {
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DataPath != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            DataPath = "EXE\\" + e [0].ToString() + "\\";
                        }
                    }
                    break;

                case "jsonresources":
                    JsonResources = new Tuple <string, string>(resolveFileEXE(s[0][0].ToString()), resolveFileEXE(s[0][1].ToString()));
                    break;

                case "resources":
                    Resources = new List <DllFile> ();
                    //NOTE: Freelancer hardcodes resources.dll
                    string pathStr;
                    if ((pathStr = resolveFileEXE("resources.dll")) != null)
                    {
                        Resources.Add(new DllFile(pathStr, vfs));
                    }
                    else
                    {
                        FLLog.Warning("Dll", "resources.dll not found");
                    }
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() != "dll")
                        {
                            continue;
                        }
                        if ((pathStr = resolveFileEXE(e[0].ToString())) != null)
                        {
                            Resources.Add(new DllFile(pathStr, vfs));
                        }
                        else
                        {
                            FLLog.Warning("Dll", e[0].ToString());
                        }
                    }
                    break;

                case "startup":
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() != "movie_file")
                        {
                            continue;
                        }
                        StartupMovies.Add(e [0].ToString());
                    }
                    break;

                case "extended":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "xinterface":
                            if (System.IO.Directory.Exists(e[0].ToString()))
                            {
                                XInterfacePath = e[0].ToString();
                            }
                            else
                            {
                                XInterfacePath = DataPath + e[0].ToString();
                            }
                            if (!XInterfacePath.EndsWith("\\", StringComparison.InvariantCulture) &&
                                !XInterfacePath.EndsWith("/", StringComparison.InvariantCulture))
                            {
                                XInterfacePath += "/";
                            }
                            break;

                        case "dataversion":
                            DataVersion = e[0].ToString();
                            break;

                        case "nonavmap":
                            if (!extNoNavmaps)
                            {
                                NoNavmapSystems = new List <string>(); extNoNavmaps = true;
                            }
                            NoNavmapSystems.Add(e[0].ToString());
                            break;

                        case "hidefaction":
                            if (!extHideFac)
                            {
                                HiddenFactions = new List <string>();  extHideFac = true;
                            }
                            ;
                            HiddenFactions.Add(e[0].ToString());
                            break;
                        }
                    }
                    break;

                case "data":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "solar":
                            SolarPath = DataPath + e [0].ToString();
                            break;

                        case "universe":
                            UniversePath = DataPath + e [0].ToString();
                            break;

                        case "equipment":
                            EquipmentPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "loadouts":
                            LoadoutPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "stars":
                            StarsPath = DataPath + e [0].ToString();
                            break;

                        case "bodyparts":
                            BodypartsPath = DataPath + e [0].ToString();
                            break;

                        case "costumes":
                            CostumesPath = DataPath + e [0];
                            break;

                        case "sounds":
                            SoundPaths.Add(DataPath + e[0]);
                            break;

                        case "ships":
                            ShiparchPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "rich_fonts":
                            RichFontPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "fonts":
                            FontPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "igraph":
                            GraphPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "effect_shapes":
                            EffectShapesPath = DataPath + e[0].ToString();
                            break;

                        case "effects":
                            EffectPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "asteroids":
                            AsteroidPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "petaldb":
                            PetalDbPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "hud":
                            HudPath = DataPath + e[0].ToString();
                            break;

                        case "goods":
                            GoodsPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "markets":
                            MarketsPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "fuses":
                            FusePaths.Add(DataPath + e[0].ToString());
                            break;

                        case "newchardb":
                            NewCharDBPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "voices":
                            VoicePaths.Add(DataPath + e[0].ToString());
                            break;
                        }
                    }
                    break;
                }
            }
        }
示例#2
0
        public FreelancerIni(string path, FileSystem vfs)
        {
            if (vfs == null)
            {
                throw new ArgumentNullException(nameof(vfs), "vfs cannot be null");
            }
            IsLibrelancer = path.EndsWith("librelancer.ini", StringComparison.OrdinalIgnoreCase);
            if (IsLibrelancer)
            {
                DacomPath = null;
            }
            EquipmentPaths = new List <string> ();
            LoadoutPaths   = new List <string> ();
            ShiparchPaths  = new List <string> ();
            SoundPaths     = new List <string>();
            GraphPaths     = new List <string>();
            EffectPaths    = new List <string>();
            AsteroidPaths  = new List <string> ();
            RichFontPaths  = new List <string>();
            FontPaths      = new List <string>();
            PetalDbPaths   = new List <string>();
            StartupMovies  = new List <string>();
            GoodsPaths     = new List <string>();
            MarketsPaths   = new List <string>();
            FusePaths      = new List <string>();
            NewCharDBPaths = new List <string>();
            VoicePaths     = new List <string>();
            bool extNoNavmaps = false;
            bool extHideFac   = false;

            NoNavmapSystems = new List <string>(NoNavmaps);
            HiddenFactions  = new List <string>(NoShowFactions);

            var fullPath = vfs.Resolve(path);

            foreach (Section s in ParseFile(fullPath, vfs))
            {
                switch (s.Name.ToLowerInvariant())
                {
                case "freelancer":
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() == "data path")
                        {
                            if (e.Count != 1)
                            {
                                throw new Exception("Invalid number of values in " + s.Name + " Entry " + e.Name + ": " + e.Count);
                            }
                            if (DataPath != null)
                            {
                                throw new Exception("Duplicate " + e.Name + " Entry in " + s.Name);
                            }
                            if (IsLibrelancer)
                            {
                                DataPath = EndInSep(e[0].ToString());
                            }
                            else
                            {
                                DataPath = "EXE\\" + EndInSep(e[0].ToString());
                            }
                        }
                        if (e.Name.ToLowerInvariant() == "dacom path")
                        {
                            DacomPath = e[0].ToString();
                        }
                    }
                    break;

                case "jsonresources":
                    JsonResources = new List <string>();
                    foreach (var e in s)
                    {
                        if (e.Name.ToLowerInvariant() != "file")
                        {
                            FLLog.Warning("Ini", $"Unexpected entry `{e.Name}` in [JsonResources] (expected file)");
                            continue;
                        }
                        JsonResources.Add(DataPath + e[0].ToString());
                    }
                    break;

                case "resources":
                    Resources = new List <DllFile> ();
                    //NOTE: Freelancer hardcodes resources.dll
                    //Not hardcoded for librelancer.ini as it will break
                    string start = IsLibrelancer ? "" : "EXE\\";
                    string pathStr;
                    if (!IsLibrelancer)
                    {
                        if ((pathStr = vfs.Resolve(start + "resources.dll", false)) != null)
                        {
                            Resources.Add(new DllFile(pathStr, vfs));
                        }
                        else
                        {
                            FLLog.Warning("Dll", "resources.dll not found");
                        }
                    }
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() != "dll")
                        {
                            continue;
                        }
                        if ((pathStr = vfs.Resolve(start + e[0].ToString(), false)) != null)
                        {
                            Resources.Add(new DllFile(pathStr, vfs));
                        }
                        else
                        {
                            FLLog.Warning("Dll", e[0].ToString());
                        }
                    }
                    break;

                case "startup":
                    foreach (Entry e in s)
                    {
                        if (e.Name.ToLowerInvariant() != "movie_file")
                        {
                            continue;
                        }
                        StartupMovies.Add(e [0].ToString());
                    }
                    break;

                case "extended":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "xinterface":
                            if (System.IO.Directory.Exists(e[0].ToString()))
                            {
                                XInterfacePath = e[0].ToString();
                            }
                            else
                            {
                                XInterfacePath = DataPath + e[0].ToString();
                            }
                            if (!XInterfacePath.EndsWith("\\", StringComparison.InvariantCulture) &&
                                !XInterfacePath.EndsWith("/", StringComparison.InvariantCulture))
                            {
                                XInterfacePath += "/";
                            }
                            break;

                        case "dataversion":
                            DataVersion = e[0].ToString();
                            break;

                        case "nonavmap":
                            if (!extNoNavmaps)
                            {
                                NoNavmapSystems = new List <string>(); extNoNavmaps = true;
                            }
                            NoNavmapSystems.Add(e[0].ToString());
                            break;

                        case "hidefaction":
                            if (!extHideFac)
                            {
                                HiddenFactions = new List <string>();  extHideFac = true;
                            }
                            ;
                            HiddenFactions.Add(e[0].ToString());
                            break;
                        }
                    }
                    break;

                case "data":
                    foreach (Entry e in s)
                    {
                        switch (e.Name.ToLowerInvariant())
                        {
                        case "solar":
                            SolarPath = DataPath + e [0].ToString();
                            break;

                        case "universe":
                            UniversePath = DataPath + e [0].ToString();
                            break;

                        case "equipment":
                            EquipmentPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "loadouts":
                            LoadoutPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "stars":
                            StarsPath = DataPath + e [0].ToString();
                            break;

                        case "bodyparts":
                            BodypartsPath = DataPath + e [0].ToString();
                            break;

                        case "costumes":
                            CostumesPath = DataPath + e [0];
                            break;

                        case "sounds":
                            SoundPaths.Add(DataPath + e[0]);
                            break;

                        case "ships":
                            ShiparchPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "rich_fonts":
                            RichFontPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "fonts":
                            FontPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "igraph":
                            GraphPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "effect_shapes":
                            EffectShapesPath = DataPath + e[0].ToString();
                            break;

                        case "effects":
                            EffectPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "asteroids":
                            AsteroidPaths.Add(DataPath + e [0].ToString());
                            break;

                        case "petaldb":
                            PetalDbPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "hud":
                            HudPath = DataPath + e[0].ToString();
                            break;

                        case "goods":
                            GoodsPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "markets":
                            MarketsPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "fuses":
                            FusePaths.Add(DataPath + e[0].ToString());
                            break;

                        case "newchardb":
                            NewCharDBPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "voices":
                            VoicePaths.Add(DataPath + e[0].ToString());
                            break;

                        //extended
                        case "newplayer":
                            NewPlayerPath = DataPath + e[0].ToString();
                            break;

                        case "mpnewcharacter":
                            MpNewCharacterPath = DataPath + e[0].ToString();
                            break;

                        case "mbases":
                            if (MBasesPaths == null)
                            {
                                MBasesPaths = new List <string>();
                            }
                            MBasesPaths.Add(DataPath + e[0].ToString());
                            break;

                        case "mouse":
                            MousePath = DataPath + e[0].ToString();
                            break;

                        case "cameras":
                            CamerasPath = DataPath + e[0].ToString();
                            break;

                        case "constants":
                            ConstantsPath = DataPath + e[0].ToString();
                            break;

                        case "navmap":
                            NavmapPath = DataPath + e[0].ToString();
                            break;
                        }
                    }
                    break;
                }
            }

            if (string.IsNullOrEmpty(MousePath))
            {
                MousePath = DataPath + "mouse.ini";
            }
            if (string.IsNullOrEmpty(CamerasPath))
            {
                CamerasPath = DataPath + "cameras.ini";
            }
            if (string.IsNullOrEmpty(ConstantsPath))
            {
                ConstantsPath = DataPath + "constants.ini";
            }
        }
示例#3
0
        public void LoadData()
        {
            if (Loaded)
            {
                return;
            }
            if (LoadDacom)
            {
                if (!string.IsNullOrEmpty(Freelancer.DacomPath))
                {
                    Dacom = new DacomIni(Freelancer.DacomPath, VFS);
                }
                else
                {
                    new MaterialMap(); //no dacom, make default global thing
                    //todo: fix this
                }
            }

            if (Freelancer.JsonResources != null)
            {
                Infocards = new InfocardManager(Freelancer.JsonResources, VFS);
            }
            else
            {
                Infocards = new InfocardManager(Freelancer.Resources);
            }

            List <Task> tasks = new List <Task>();

            tasks.Add(Task.Run(() =>
            {
                Equipment = new EquipmentIni();
                foreach (var eq in Freelancer.EquipmentPaths)
                {
                    Equipment.AddEquipmentIni(eq, this);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Solar = new SolararchIni(Freelancer.SolarPath, this);
                if (Freelancer.StarsPath != null)
                {
                    Stars = new StararchIni(Freelancer.StarsPath, VFS);
                }
                else
                {
                    Stars = new StararchIni(Freelancer.DataPath + "SOLAR\\stararch.ini", VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Asteroids = new AsteroidArchIni();
                foreach (var ast in Freelancer.AsteroidPaths)
                {
                    Asteroids.AddFile(ast, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                SpecificNPCs = new SpecificNPCIni();
                if (VFS.FileExists(Freelancer.DataPath + "MISSIONS\\specific_npc.ini"))
                {
                    SpecificNPCs.AddFile(Freelancer.DataPath + "MISSIONS\\specific_npc.ini", VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Loadouts = new LoadoutsIni();
                foreach (var lo in Freelancer.LoadoutPaths)
                {
                    Loadouts.AddLoadoutsIni(lo, this);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Universe = new UniverseIni(Freelancer.UniversePath, this);
            }));
            //Pilots
            tasks.Add(Task.Run(() =>
            {
                Pilots = new PilotsIni();
                if (VFS.FileExists(Freelancer.DataPath + "MISSIONS\\pilots_population.ini"))
                {
                    Pilots.AddFile(Freelancer.DataPath + "MISSIONS\\pilots_population.ini", VFS);
                }
                if (VFS.FileExists(Freelancer.DataPath + "MISSIONS\\pilots_story.ini"))
                {
                    Pilots.AddFile(Freelancer.DataPath + "MISSIONS\\pilots_story.ini", VFS);
                }
            }));
            //Graphs
            tasks.Add(Task.Run(() =>
            {
                Graphs = new GraphIni();
                foreach (var g in Freelancer.GraphPaths)
                {
                    Graphs.AddGraphIni(g, VFS);
                }
            }));
            //Shapes
            tasks.Add(Task.Run(() =>
            {
                if (string.IsNullOrEmpty(Freelancer.EffectShapesPath))
                {
                    throw new Exception("Need one effect_shapes entry");
                }
                EffectShapes = new TexturePanels(Freelancer.EffectShapesPath, VFS);
            }));
            //Effects
            tasks.Add(Task.Run(() =>
            {
                Effects = new EffectsIni();
                foreach (var fx in Freelancer.EffectPaths)
                {
                    Effects.AddIni(fx, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                //Mouse
                Mouse = new MouseIni(Freelancer.MousePath, VFS);
                //Fonts
                RichFonts = new RichFontsIni();
                foreach (var rf in Freelancer.RichFontPaths)
                {
                    RichFonts.AddRichFontsIni(rf, VFS);
                }
                Fonts = new FontsIni();
                foreach (var f in Freelancer.FontPaths)
                {
                    Fonts.AddFontsIni(f, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                //PetalDb
                PetalDb = new PetalDbIni();
                foreach (var pt in Freelancer.PetalDbPaths)
                {
                    PetalDb.AddFile(pt, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                //Hud
                Hud = new HudIni();
                if (string.IsNullOrEmpty(Freelancer.HudPath))
                {
                    throw new Exception("Need one hud path");
                }
                Hud.AddIni(Freelancer.HudPath, VFS);
                //navbar.ini
                BaseNavBar = new BaseNavBarIni(Freelancer.DataPath, VFS);
                if (!string.IsNullOrEmpty(Freelancer.NavmapPath))
                {
                    Navmap = new NavmapIni(Freelancer.NavmapPath, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                InfocardMap = new InfocardMapIni();
                InfocardMap.AddMap(Freelancer.DataPath + "/INTERFACE/infocardmap.ini", VFS);
            }));
            tasks.Add(Task.Run(() =>
            {
                //mbases.ini
                MBases = new MBasesIni();
                if (Freelancer.MBasesPaths != null)
                {
                    foreach (var f in Freelancer.MBasesPaths)
                    {
                        MBases.AddFile(f, VFS);
                    }
                }
                else
                {
                    MBases.AddFile(Freelancer.DataPath + "MISSIONS\\mbases.ini", VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                News = new NewsIni();
                if (VFS.FileExists(Freelancer.DataPath + "MISSIONS\\news.ini"))
                {
                    News.AddNewsIni(Freelancer.DataPath + "MISSIONS\\news.ini", VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Fuses = new FuseIni();
                foreach (var fi in Freelancer.FusePaths)
                {
                    Fuses.AddFuseIni(fi, VFS);
                }
            }));
            //newchardb
            tasks.Add(Task.Run(() =>
            {
                NewCharDB = new NewCharDBIni();
                foreach (var nc in Freelancer.NewCharDBPaths)
                {
                    NewCharDB.AddNewCharDBIni(nc, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Bodyparts = new BodypartsIni(Freelancer.BodypartsPath, this);
                Costumes  = new CostumesIni(Freelancer.CostumesPath, this);
            }));
            tasks.Add(Task.Run(() =>
            {
                Audio = new AudioIni();
                foreach (var snd in Freelancer.SoundPaths)
                {
                    Audio.AddIni(snd, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Ships = new ShiparchIni();
                foreach (var shp in Freelancer.ShiparchPaths)
                {
                    Ships.AddShiparchIni(shp, this);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Goods = new GoodsIni();
                foreach (var gd in Freelancer.GoodsPaths)
                {
                    Goods.AddGoodsIni(gd, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Markets = new MarketsIni();
                foreach (var mkt in Freelancer.MarketsPaths)
                {
                    Markets.AddMarketsIni(mkt, VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                foreach (var msn in missionFiles)
                {
                    if (VFS.FileExists(Freelancer.DataPath + msn))
                    {
                        var m = new MissionIni(Freelancer.DataPath + msn, VFS);
                        if (m.Info?.NpcShipFile != null)
                        {
                            m.ShipIni = new NPCShipIni(Freelancer.DataPath + m.Info.NpcShipFile, VFS);
                        }
                        Missions.Add(m);
                    }
                }

                if (VFS.FileExists(Freelancer.DataPath + "missions\\npcships.ini"))
                {
                    NPCShips = new NPCShipIni(Freelancer.DataPath + "missions\\npcships.ini", VFS);
                }
            }));
            tasks.Add(Task.Run(() =>
            {
                Cameras = new CameraIni();
                Cameras.ParseAndFill(Freelancer.CamerasPath, VFS);
            }));
            tasks.Add(Task.Run(() =>
            {
                HpTypes = new HpTypesIni();
                HpTypes.LoadDefault();
            }));
            ContentDll = new ContentDll();
            if (VFS.FileExists("DLLS\\BIN\\content.dll"))
            {
                ContentDll.Load(VFS.Resolve("DLLS\\BIN\\content.dll"));
            }
            if (!string.IsNullOrEmpty(Freelancer.DataVersion))
            {
                DataVersion = Freelancer.DataVersion;
            }
            else
            {
                DataVersion = "FL-1";
            }
            Task.WaitAll(tasks.ToArray());
            Loaded = true;
        }
示例#4
0
        public void LoadData()
        {
            if (Loaded)
            {
                return;
            }
            if (LoadDacom)
            {
                Dacom = new DacomIni(VFS);
            }
            if (Freelancer.JsonResources != null)
            {
                Infocards = new InfocardManager(File.ReadAllText(Freelancer.JsonResources.Item1), File.ReadAllText(Freelancer.JsonResources.Item2));
            }
            else
            {
                Infocards = new InfocardManager(Freelancer.Resources);
            }

            var t1 = Task.Run(() =>
            {
                Equipment = new EquipmentIni();
                foreach (var eq in Freelancer.EquipmentPaths)
                {
                    Equipment.AddEquipmentIni(eq, this);
                }
            });
            var t2 = Task.Run(() =>
            {
                Solar = new SolararchIni(Freelancer.SolarPath, this);
                if (Freelancer.StarsPath != null)
                {
                    Stars = new StararchIni(Freelancer.StarsPath, VFS);
                }
                else
                {
                    Stars = new StararchIni("DATA\\SOLAR\\stararch.ini", VFS);
                }
            });
            var t3 = Task.Run(() =>
            {
                Asteroids = new AsteroidArchIni();
                foreach (var ast in Freelancer.AsteroidPaths)
                {
                    Asteroids.AddFile(ast, VFS);
                }
            });
            var t4 = Task.Run(() =>
            {
                Loadouts = new LoadoutsIni();
                foreach (var lo in Freelancer.LoadoutPaths)
                {
                    Loadouts.AddLoadoutsIni(lo, this);
                }
            });
            var t5 = Task.Run(() =>
            {
                Universe = new UniverseIni(Freelancer.UniversePath, this);
            });
            //Graphs
            var t6 = Task.Run(() =>
            {
                Graphs = new GraphIni();
                foreach (var g in Freelancer.GraphPaths)
                {
                    Graphs.AddGraphIni(g, VFS);
                }
            });
            //Shapes
            var t7 = Task.Run(() =>
            {
                EffectShapes = new TexturePanels(Freelancer.EffectShapesPath, VFS);
            });
            //Effects
            var t8 = Task.Run(() =>
            {
                Effects = new EffectsIni();
                foreach (var fx in Freelancer.EffectPaths)
                {
                    Effects.AddIni(fx, VFS);
                }
            });
            var t9 = Task.Run(() =>
            {
                //Mouse
                Mouse = new MouseIni(Freelancer.DataPath + "/mouse.ini", VFS);
                //Fonts
                RichFonts = new RichFontsIni();
                foreach (var rf in Freelancer.RichFontPaths)
                {
                    RichFonts.AddRichFontsIni(rf, VFS);
                }
                Fonts = new FontsIni();
                foreach (var f in Freelancer.FontPaths)
                {
                    Fonts.AddFontsIni(f, VFS);
                }
            });
            var t10 = Task.Run(() =>
            {
                //PetalDb
                PetalDb = new PetalDbIni();
                foreach (var pt in Freelancer.PetalDbPaths)
                {
                    PetalDb.AddFile(pt, VFS);
                }
            });
            var t11 = Task.Run(() =>
            {
                //Hud
                Hud = new HudIni();
                Hud.AddIni(Freelancer.HudPath, VFS);
                //navbar.ini
                BaseNavBar = new BaseNavBarIni(VFS);
            });
            var t12 = Task.Run(() =>
            {
                //mbases.ini
                MBases = new MBasesIni(VFS);
            });
            var t14 = Task.Run(() =>
            {
                Fuses = new FuseIni();
                foreach (var fi in Freelancer.FusePaths)
                {
                    Fuses.AddFuseIni(fi, VFS);
                }
            });
            //newchardb
            var t15 = Task.Run(() =>
            {
                NewCharDB = new NewCharDBIni();
                foreach (var nc in Freelancer.NewCharDBPaths)
                {
                    NewCharDB.AddNewCharDBIni(nc, VFS);
                }
            });
            var t16 = Task.Run(() =>
            {
                Bodyparts = new BodypartsIni(Freelancer.BodypartsPath, this);
                Costumes  = new CostumesIni(Freelancer.CostumesPath, this);
            });
            var t18 = Task.Run(() =>
            {
                Audio = new AudioIni();
                foreach (var snd in Freelancer.SoundPaths)
                {
                    Audio.AddIni(snd, VFS);
                }
            });
            var t19 = Task.Run(() =>
            {
                Ships = new ShiparchIni();
                foreach (var shp in Freelancer.ShiparchPaths)
                {
                    Ships.AddShiparchIni(shp, this);
                }
            });
            var t20 = Task.Run(() =>
            {
                Goods = new GoodsIni();
                foreach (var gd in Freelancer.GoodsPaths)
                {
                    Goods.AddGoodsIni(gd, VFS);
                }
            });
            var t21 = Task.Run(() =>
            {
                Markets = new MarketsIni();
                foreach (var mkt in Freelancer.MarketsPaths)
                {
                    Markets.AddMarketsIni(mkt, VFS);
                }
            });
            var t22 = Task.Run(() =>
            {
                foreach (var msn in missionFiles)
                {
                    if (VFS.FileExists(Freelancer.DataPath + msn))
                    {
                        Missions.Add(new Data.Missions.MissionIni(Freelancer.DataPath + msn, VFS));
                    }
                }
            });

            ContentDll = new ContentDll();
            if (VFS.FileExists("DLLS\\BIN\\content.dll"))
            {
                ContentDll.Load(VFS.Resolve("DLLS\\BIN\\content.dll"));
            }
            if (!string.IsNullOrEmpty(Freelancer.DataVersion))
            {
                DataVersion = Freelancer.DataVersion;
            }
            else
            {
                DataVersion = "FL-1";
            }
            //Yes I screwed up the numbering
            Task.WaitAll(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t14, t15, t16, t18, t19, t20, t21, t22);
            Loaded = true;
        }
示例#5
0
        public void LoadData()
        {
            if (Loaded)
            {
                return;
            }
            if (LoadDacom)
            {
                Dacom = new DacomIni(VFS);
            }
            if (Freelancer.JsonResources != null)
            {
                Infocards = new InfocardManager(File.ReadAllText(Freelancer.JsonResources.Item1), File.ReadAllText(Freelancer.JsonResources.Item2));
            }
            else
            {
                Infocards = new InfocardManager(Freelancer.Resources);
            }
            //Build Universe
            var tSolar = new Thread(() =>
            {
                //Equipment
                Equipment = new EquipmentIni();
                foreach (var eq in Freelancer.EquipmentPaths)
                {
                    Equipment.AddEquipmentIni(eq, this);
                }
                Solar = new SolararchIni(Freelancer.SolarPath, this);
                if (Freelancer.StarsPath != null)
                {
                    Stars = new StararchIni(Freelancer.StarsPath, VFS);
                }
                else
                {
                    Stars = new StararchIni("DATA\\SOLAR\\stararch.ini", VFS);
                }
                Asteroids = new AsteroidArchIni();
                foreach (var ast in Freelancer.AsteroidPaths)
                {
                    Asteroids.AddFile(ast, VFS);
                }
                Loadouts = new LoadoutsIni();
                foreach (var lo in Freelancer.LoadoutPaths)
                {
                    Loadouts.AddLoadoutsIni(lo, this);
                }
            });
            var tUniverse = new Thread(() =>
            {
                Universe = new UniverseIni(Freelancer.UniversePath, this);
            });
            //Misc
            var tMisc = new Thread(() =>
            {
                //Graphs
                Graphs = new GraphIni();
                foreach (var g in Freelancer.GraphPaths)
                {
                    Graphs.AddGraphIni(g, VFS);
                }
                //Shapes
                EffectShapes = new TexturePanels(Freelancer.EffectShapesPath, VFS);
                //Effects
                Effects = new EffectsIni();
                foreach (var fx in Freelancer.EffectPaths)
                {
                    Effects.AddIni(fx, VFS);
                }
                //Mouse
                Mouse = new MouseIni(Freelancer.DataPath + "//mouse.ini", VFS);
                //Fonts
                RichFonts = new RichFontsIni();
                foreach (var rf in Freelancer.RichFontPaths)
                {
                    RichFonts.AddRichFontsIni(rf, VFS);
                }
                Fonts = new FontsIni();
                foreach (var f in Freelancer.FontPaths)
                {
                    Fonts.AddFontsIni(f, VFS);
                }
                //PetalDb
                PetalDb = new PetalDbIni();
                foreach (var pt in Freelancer.PetalDbPaths)
                {
                    PetalDb.AddFile(pt, VFS);
                }
                //Hud
                Hud = new HudIni();
                Hud.AddIni(Freelancer.HudPath, VFS);
                //navbar.ini
                BaseNavBar = new BaseNavBarIni(VFS);
                //mbases.ini
                MBases = new MBasesIni(VFS);
                //fuses
                Fuses = new FuseIni();
                foreach (var fi in Freelancer.FusePaths)
                {
                    Fuses.AddFuseIni(fi, VFS);
                }
                //newchardb
                NewCharDB = new NewCharDBIni();
                foreach (var nc in Freelancer.NewCharDBPaths)
                {
                    NewCharDB.AddNewCharDBIni(nc, VFS);
                }
            });

            tMisc.Start();
            tSolar.Start();
            tUniverse.Start();
            Bodyparts = new BodypartsIni(Freelancer.BodypartsPath, this);
            Costumes  = new CostumesIni(Freelancer.CostumesPath, this);
            Audio     = new AudioIni();
            foreach (var snd in Freelancer.SoundPaths)
            {
                Audio.AddIni(snd, VFS);
            }
            Ships = new ShiparchIni();
            foreach (var shp in Freelancer.ShiparchPaths)
            {
                Ships.AddShiparchIni(shp, this);
            }
            Goods = new GoodsIni();
            foreach (var gd in Freelancer.GoodsPaths)
            {
                Goods.AddGoodsIni(gd, VFS);
            }
            Markets = new MarketsIni();
            foreach (var mkt in Freelancer.MarketsPaths)
            {
                Markets.AddMarketsIni(mkt, VFS);
            }
            foreach (var msn in missionFiles)
            {
                if (VFS.FileExists(Freelancer.DataPath + msn))
                {
                    Missions.Add(new Data.Missions.MissionIni(Freelancer.DataPath + msn, VFS));
                }
            }
            ContentDll = new ContentDll();
            if (VFS.FileExists("DLLS\\BIN\\content.dll"))
            {
                ContentDll.Load(VFS.Resolve("DLLS\\BIN\\content.dll"));
            }
            tSolar.Join();
            tMisc.Join();
            tUniverse.Join();
            if (!string.IsNullOrEmpty(Freelancer.DataVersion))
            {
                DataVersion = Freelancer.DataVersion;
            }
            else
            {
                DataVersion = "FL-1";
            }
            Loaded = true;
        }