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 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 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 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; }
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)); }