コード例 #1
0
        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);
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
            }
        }
コード例 #9
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
        }
コード例 #10
0
        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));
        }