public FreelancerIni(string path) { 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>(); PetalDbPaths = new List <string>(); StartupMovies = new List <string>(); GoodsPaths = new List <string>(); MarketsPaths = new List <string>(); FusePaths = new List <string>(); NewCharDBPaths = 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.GetPath(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)) { 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)); } 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)); } 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 "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; } } break; } } }
public void LoadData() { if (Loaded) { return; } if (LoadDacom) { Dacom = new DacomIni(); } 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); } else { Stars = new StararchIni("DATA\\SOLAR\\stararch.ini"); } Asteroids = new AsteroidArchIni(); foreach (var ast in Freelancer.AsteroidPaths) { Asteroids.AddFile(ast); } 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); } //Shapes EffectShapes = new TexturePanels(Freelancer.EffectShapesPath); //Effects Effects = new EffectsIni(); foreach (var fx in Freelancer.EffectPaths) { Effects.AddIni(fx); } //Mouse Mouse = new MouseIni(Freelancer.DataPath + "//mouse.ini"); //Fonts RichFonts = new RichFontsIni(); foreach (var rf in Freelancer.RichFontPaths) { RichFonts.AddRichFontsIni(rf); } //PetalDb PetalDb = new PetalDbIni(); foreach (var pt in Freelancer.PetalDbPaths) { PetalDb.AddFile(pt); } //Hud Hud = new HudIni(); Hud.AddIni(Freelancer.HudPath); //navbar.ini BaseNavBar = new BaseNavBarIni(); //mbases.ini MBases = new MBasesIni(); //fuses Fuses = new FuseIni(); foreach (var fi in Freelancer.FusePaths) { Fuses.AddFuseIni(fi); } //newchardb NewCharDB = new NewCharDBIni(); foreach (var nc in Freelancer.NewCharDBPaths) { NewCharDB.AddNewCharDBIni(nc); } }); 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, Freelancer); } 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); } Markets = new MarketsIni(); foreach (var mkt in Freelancer.MarketsPaths) { Markets.AddMarketsIni(mkt); } foreach (var msn in missionFiles) { if (VFS.FileExists(Freelancer.DataPath + msn)) { Missions.Add(new Data.Missions.MissionIni(Freelancer.DataPath + msn)); } } ContentDll = new ContentDll(); if (VFS.FileExists("DLLS\\BIN\\content.dll")) { ContentDll.Load(VFS.GetPath("DLLS\\BIN\\content.dll")); } tSolar.Join(); tMisc.Join(); tUniverse.Join(); if (!string.IsNullOrEmpty(Freelancer.DataVersion)) { DataVersion = Freelancer.DataVersion; } else { DataVersion = "FL-1"; } Loaded = true; }