static void Main(string[] args) { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); }
public void testInit() { EdataManager dataManager = new EdataManager(NDF_PATH); dataManager.ParseEdataFile(); NdfbinManager everything = dataManager.ReadNdfbin(EVERYTHING_NDFBIN); List <NdfObject> unitInstances = everything.GetClass("TUniteAuSolDescriptor").Instances; // setup localisation/unites.dic reader EdataManager dataManager2 = new EdataManager(ZZ_PATH); dataManager2.ParseEdataFile(); TradManager dict = dataManager2.ReadDictionary(UNITES_DIC); // unit icons EdataManager zz4File = new EdataManager(ZZ4_PATH); zz4File.ParseEdataFile(); EdataManager iconPackage = zz4File.ReadPackage(ICON_PACKAGE); UnitDatabase unitDatabase = new UnitDatabase(unitInstances, dict, iconPackage, PACT_ICONS_DIRPREFIX, NATO_ICONS_DIRPREFIX); List <String> countries = unitDatabase.getAllCountries(); CollectionAssert.AllItemsAreUnique(countries); Assert.IsTrue(countries.Count > 0); }
public void LoadNdf() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); Assert.IsTrue(datamana.Files.Count > 0); }
public void LoadNdfbin() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); Assert.IsTrue(ndfbin.Classes.Count > 0); }
public UnitDatabase getUnitDatabase(Form1 caller, String version) { // We deregister the requesting form from whatever previous version it was using, // register it with the new version and create or find a database for it. // deregister foreach (List <Form1> item in databaseIndex.Values) { item.Remove(caller); } // Check if a database exists or if we will have to create: List <Form1> val = null; if (databaseIndex.TryGetValue(version, out val) && val.Any()) { UnitDatabase result = val.First().unitDatabase.clone(); // register val.Add(caller); return(result); } else { // register val = new List <Form1>(); val.Add(caller); databaseIndex.Remove(version); databaseIndex.Add(version, val); // create EdataManager dataManager = new EdataManager(singleton.paths.getNdfPath(version)); try { dataManager.ParseEdataFile(); } catch (System.IO.IOException) { Program.warning("IOException thrown, could not parse " + singleton.paths.getNdfPath() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); } NdfbinManager everything = dataManager.ReadNdfbin(EVERYTHING_NDFBIN); List <NdfObject> unitInstances = everything.GetClass("TUniteAuSolDescriptor").Instances; UnitDatabase database = new UnitDatabase(unitInstances, dict, iconPackage, PACT_ICONS_DIRPREFIX, NATO_ICONS_DIRPREFIX); // Transfer weapon lock if (caller.unitDatabase != null && caller.unitDatabase.getLockIndexedWeapon() != null) { database.setCurrentWeapon(caller.unitDatabase.getLockIndexedWeapon()); database.lockWeapon(); } return(database); } }
public void LoadClass() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass(className); Assert.IsTrue(claass.Instances.Count > 0); }
public void LoadFile(string path) { EdataManager = new EdataManager(path); LoadedFile = EdataManager.FilePath; EdataManager.ParseEdataFile(); Files = EdataManager.Files; CreateFilesCollectionView(); }
public void LoadInstance() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass(className); NdfObject obj = claass.Instances[0]; Assert.IsTrue(obj.PropertyValues.Count > 0); }
public void ReadCost() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass("TUniteDescriptor"); NdfObject obj = claass.Instances[1]; NdfUInt32 refef; Assert.IsTrue(obj.TryGetValueFromQuery <NdfUInt32>(UNIT_REA_COST, out refef)); }
public void LoadTGV() { EdataManager manager = new EdataManager(@"C:\Users\mja\Documents\perso\mods\commoninterface.ppk"); manager.ParseEdataFile(); string filename = @"pc\texture\assets\2d\interface\common\unitsicons\us\stryker_icv_upgrade_1.tgv"; Bitmap bitmap = null; Assert.IsTrue(manager.TryToLoadTgv(filename, out bitmap)); Assert.IsNotNull(bitmap); bitmap.Save("Unit2.png"); }
public void LoadProperty() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass(className); NdfObject obj = claass.Instances[1]; NdfString uint32; obj.TryGetValueFromQuery <NdfString>(UNIT_ICON, out uint32); }
public void QueryReference() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass("TUniteDescriptor"); NdfObject obj = claass.Instances[1]; NdfObjectReference refef; string query = "Modules.TypeUnit.Default"; Assert.IsTrue(obj.TryGetValueFromQuery <NdfObjectReference>(query, out refef)); }
public DataType GetDataSource <DataType>(string sourceDataPath) { var separator = sourceDataPath.LastIndexOf(':'); var sourceDataFile = sourceDataPath.Substring(0, separator); var dataObjectPath = sourceDataPath.Substring(separator + 1); if (!_dataSources.ContainsKey(sourceDataFile)) { EdataManager eManager = new EdataManager(sourceDataFile); eManager.ParseEdataFile(); _dataSources.Add(sourceDataFile, new Tuple <EdataManager, Dictionary <string, object> >(eManager, new Dictionary <string, object>())); } var src = _dataSources[sourceDataFile]; var dataManager = src.Item1; var dataObjectDic = src.Item2; var dataObject = dataObjectDic.FirstOrDefault(x => x.Key == dataObjectPath).Value; if (dataObject != null) { return((DataType)dataObject); } else { var dataContentFile = dataManager.Files.FirstOrDefault(f => f.Path.Contains(dataObjectPath)); if (typeof(DataType) == typeof(NdfBinary)) { var ndfbinReader = new NdfbinReader(); object ndfBinary = ndfbinReader.Read(dataManager.GetRawData(dataContentFile)); dataObjectDic.Add(dataObjectPath, ndfBinary); return((DataType)ndfBinary); } if (typeof(DataType) == typeof(TradManager)) { object tm = new TradManager(dataManager.GetRawData(dataContentFile)); dataObjectDic.Add(dataObjectPath, tm); return((DataType)tm); } // Other types not implemented. throw new NotImplementedException(); } }
public void LoadTGVFromZZ4() { string zz4 = @"C:\Users\mja\Documents\perso\mods\ZZ_4.dat"; EdataManager zz4File = new EdataManager(zz4); zz4File.ParseEdataFile(); string filename = @"pc\texture\assets\2d\interface\common\unitsicons\cs\m8_losat_upb.tgv"; string ICON_PACKAGE = @"pc\texture\pack\commoninterface.ppk"; EdataManager pack = zz4File.ReadPackage(ICON_PACKAGE); Bitmap bitmap = null; Assert.IsTrue(pack.TryToLoadTgv(filename, out bitmap)); Assert.IsNotNull(bitmap); bitmap.Save("UnitDXT1.png"); }
public void TestGettingFile() { EdataManager datamanager = new EdataManager(Environment.CurrentDirectory + "/data/NDF_Win.dat"); datamanager.ParseEdataFile(); NdfbinManager ndfFile = datamanager.ReadNdfbin("pc\\ndf\\patchable\\gfx\\everything.ndfbin"); Assert.IsNotNull(ndfFile); Assert.IsTrue(ndfFile.Classes.Count > 1); NdfClass ammoClass = ndfFile.GetClass("TAmmunition"); foreach (NdfObject ammo in ammoClass.Instances) { NdfValueWrapper val; Assert.IsTrue(ammo.TryGetValueFromPath("TempsEntreDeuxTirs", out val)); } }
public void ReadDictionaryEntry() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass("TUniteDescriptor"); NdfObject obj = claass.Instances[1]; NdfLocalisationHash refef; string query = "Modules.TypeUnit.Default.DescriptionHintToken"; Assert.IsTrue(obj.TryGetValueFromQuery <NdfLocalisationHash>(query, out refef)); EdataManager dic = new EdataManager(trans); dic.ParseEdataFile(); TradManager trad = dic.ReadDictionary(transFile); string output = string.Empty; Assert.IsTrue(trad.TryGetString(refef.Value, out output)); // get LOSAT's description }
private static void readIcons() { EdataManager zz4File = new EdataManager(singleton.paths.getZz4Path()); try { zz4File.ParseEdataFile(); } catch (System.IO.IOException) { Program.warning("IOException thrown, could not parse " + singleton.paths.getZz4Path() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); singleton = null; } singleton.iconPackage = null; try { singleton.iconPackage = zz4File.ReadPackage(ICON_PACKAGE); } catch (Exception) { Program.warning("Failed reading ZZ_4.dat. May have selected an incomplete one - try pointing settings.ini to a complete ZZ_4.dat file."); singleton = null; } }
private static void readDictionaries() { EdataManager dataManager2 = new EdataManager(singleton.paths.getZzPath()); try { dataManager2.ParseEdataFile(); } catch (System.IO.IOException) { Program.warning("IOException thrown, could not parse " + singleton.paths.getZzPath() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); singleton = null; } singleton.dict = null; try { singleton.dict = dataManager2.ReadDictionary(UNITES_DIC); } catch (Exception) { Program.warning("Failed reading ZZ_Win.dat. May have selected an incomplete one - try pointing settings.ini to a complete ZZ_Win.dat file."); singleton = null; } }
public NdfDatabase(string fileName) { string everythingNdfbinPattern = @".*everything.ndfbin"; Regex regex = new Regex(everythingNdfbinPattern, RegexOptions.IgnoreCase); var ndfbinReader = new NdfbinReader(); var edataManager = new EdataManager(fileName); edataManager.ParseEdataFile(); var everythingNdfbinRaw = edataManager.Files.Where(t => regex.IsMatch(t.ToString())).First(); everythingNdfbin = ndfbinReader.Read(edataManager.GetRawData(everythingNdfbinRaw)); tShowRoomDeckSerializer = everythingNdfbin.Classes.Where(cls => cls.Name == "TShowRoomDeckSerializer").First(); tUniteAuSolDescriptor = everythingNdfbin.Classes.Where(cls => cls.Name == "TUniteAuSolDescriptor").First(); tUniteDescriptor = everythingNdfbin.Classes.Where(cls => cls.Name == "TUniteDescriptor").First(); tTransportableModuleDescriptor = everythingNdfbin.Classes.Where(cls => cls.Name == "TTransportableModuleDescriptor").First(); tShowRoomDeckRuleManager = everythingNdfbin.Classes.Where(cls => cls.Name == "TShowRoomDeckRuleManager").First(); deckRulesManagerProperties = tShowRoomDeckRuleManager.Instances[0].PropertyValues; }
public bool TryGetPackFileFromFolder(string folder, string filename, string packfile, out EdataManager pack) { pack = null; DirectoryInfo folderInfo = new DirectoryInfo(folder); FileInfo[] fileInfos = folderInfo.GetFiles(filename, SearchOption.TopDirectoryOnly); if (fileInfos.Length <= 0) return false; EdataManager dataManager = new EdataManager(fileInfos[0].FullName); dataManager.ParseEdataFile(); try { pack = dataManager.ReadPackage(packfile); return true; } catch { } return false; }
public bool TryGetDicFileFromFolder(string folder, string filename, string dicfile, out TradManager dic) { dic = null; DirectoryInfo folderInfo = new DirectoryInfo(folder); FileInfo[] fileInfos = folderInfo.GetFiles(filename, SearchOption.TopDirectoryOnly); if (fileInfos.Length <= 0) return false; EdataManager dataManager = new EdataManager(fileInfos[0].FullName); dataManager.ParseEdataFile(); try { dic = dataManager.ReadDictionary(dicfile); return true; } catch { } return false; }
public bool TryGetNdfbinFileFromFolder(string folder, string filename, string ndfbinfile, out NdfbinManager ndfbin) { ndfbin = null; DirectoryInfo folderInfo = new DirectoryInfo(folder); FileInfo[] fileInfos = folderInfo.GetFiles(filename, SearchOption.TopDirectoryOnly); if (fileInfos.Length <= 0) return false; EdataManager dataManager = new EdataManager(fileInfos[0].FullName); dataManager.ParseEdataFile(); try { ndfbin = dataManager.ReadNdfbin(ndfbinfile); return true; } catch { // TODO : Dump error to log } return false; }
static void Main() { // Print all uncaught exceptions. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( delegate(Object sender, UnhandledExceptionEventArgs e) { warning(e.ExceptionObject.ToString()); } ); // Free resources before exiting. AppDomain.CurrentDomain.ProcessExit += new EventHandler(cleanup); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PathFinder paths = new PathFinder(); // setup everything.ndfbin reader // EdataManager dataManager = new EdataManager(AppDomain.CurrentDomain.BaseDirectory + "NDF_Win.dat"); EdataManager dataManager = new EdataManager(paths.getNdfPath()); try { dataManager.ParseEdataFile(); } catch (System.IO.IOException) { warning("IOException thrown, could not parse " + paths.getNdfPath() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); Application.Exit(); Environment.Exit(0); } NdfbinManager everything = dataManager.ReadNdfbin(EVERYTHING_NDFBIN); List <NdfObject> unitInstances = everything.GetClass("TUniteAuSolDescriptor").Instances; // setup localisation/unites.dic reader EdataManager dataManager2 = new EdataManager(paths.getZzPath()); try { dataManager2.ParseEdataFile(); } catch (System.IO.IOException) { warning("IOException thrown, could not parse " + paths.getZzPath() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); Application.Exit(); Environment.Exit(0); } TradManager dict = null; try { dict = dataManager2.ReadDictionary(UNITES_DIC); } catch (Exception) { warning("Failed reading ZZ_Win.dat. May have selected an incomplete one - try pointing settings.ini to a complete ZZ_Win.dat file."); Application.Exit(); Environment.Exit(0); } // unit icons EdataManager zz4File = new EdataManager(paths.getZz4Path()); try { zz4File.ParseEdataFile(); } catch (System.IO.IOException) { warning("IOException thrown, could not parse " + paths.getZz4Path() + ".\nIf wargame is running, you'll have to close it to use the tool. You can avoid this by copying the files listed in settings.ini and then editing settings.ini to point to the copies."); Application.Exit(); Environment.Exit(0); } EdataManager iconPackage = null; try { iconPackage = zz4File.ReadPackage(ICON_PACKAGE); } catch (Exception) { warning("Failed reading ZZ_4.dat. May have selected an incomplete one - try pointing settings.ini to a complete ZZ_4.dat file."); Application.Exit(); Environment.Exit(0); } UnitDatabase unitDatabase = new UnitDatabase(unitInstances, dict, iconPackage, PACT_ICONS_DIRPREFIX, NATO_ICONS_DIRPREFIX); Application.Run(new Form1(unitDatabase, paths.autoUpdate)); }