Ejemplo n.º 1
0
        public static AppSettings LoadSettings()
        {
            try
            {
                //Try to load the settings
                YAXSerializer serializer = new YAXSerializer(typeof(AppSettings), YAXSerializationOptions.DontSerializeNullObjects);
                var           settings   = (AppSettings)serializer.DeserializeFromFile(GeneralInfo.SETTINGS_PATH);
                settings.InitSettings();
                settings.ValidateSettings();
                return(settings);
            }
            catch
            {
                //If it fails, create a new instance and save it to disk.
                var newSettings = new AppSettings()
                {
                };

                newSettings.InitSettings();
                newSettings.SaveSettings();

                return(newSettings);
            }
            finally
            {
                GeneralInfo.UpdateEepkToolInterlop();
            }
        }
Ejemplo n.º 2
0
        public static void Deserialize(string xmlPath)
        {
            string        path       = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer = new YAXSerializer(typeof(PUP_File), YAXSerializationOptions.DontSerializeNullObjects);

            Write((PUP_File)serializer.DeserializeFromFile(xmlPath), path);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Loads the specified eepk file. It can be in either binary or xml format.
 ///
 /// If a file can not be found at the specified location, then a empty one will be returned.
 /// </summary>
 public static EEPK_File LoadEepk(string path, bool returnEmptyIfNotValid = true)
 {
     if (Path.GetExtension(path) == ".eepk")
     {
         return(new Xv2CoreLib.EEPK.Parser(path, false).GetEepkFile());
     }
     else if (Path.GetExtension(path) == ".xml" && Path.GetExtension(Path.GetFileNameWithoutExtension(path)) == ".eepk")
     {
         YAXSerializer serializer = new YAXSerializer(typeof(Xv2CoreLib.EMM.EMM_File), YAXSerializationOptions.DontSerializeNullObjects);
         return((Xv2CoreLib.EEPK.EEPK_File)serializer.DeserializeFromFile(path));
     }
     else
     {
         if (returnEmptyIfNotValid)
         {
             return(new EEPK_File()
             {
                 Assets = new List <AssetContainer>(),
                 Effects = new List <Effect>()
             });
         }
         else
         {
             throw new FileNotFoundException("An .eppk could not be found at the specified location.");
         }
     }
 }
Ejemplo n.º 4
0
        public static void LoadTracker()
        {
            if (!IsGameDirValid())
            {
                return;
            }

            if (File.Exists(TrackerPath))
            {
                try
                {
                    YAXSerializer serializer = new YAXSerializer(typeof(TrackingXml), YAXSerializationOptions.DontSerializeNullObjects);
                    Tracker = (TrackingXml)serializer.DeserializeFromFile(TrackerPath);
                }
                catch
                {
                    Tracker = new TrackingXml();
                }
            }
            else
            {
                Tracker = new TrackingXml();
            }

            //Initializes the tracker
            Tracker.GetCurrentMod();
        }
Ejemplo n.º 5
0
        private void BattleStarGalactica_Load(object sender, EventArgs e)
        {
            string[] allCharFiles = null;
            string[] allEncFiles  = null;
            try
            {
                allCharFiles = Directory.GetFiles(Path.Combine(Config.PATH_BASE, "Characters"));
                allEncFiles  = Directory.GetFiles(Path.Combine(Config.PATH_BASE, "Encounters"));
            }
            catch (DirectoryNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
            if (allCharFiles == null || allEncFiles == null)
            {
                return;
            }
            createDummys(allCharFiles.Length == 0, allEncFiles.Length == 0);
            string[]      allLines;
            YAXSerializer serializer = new YAXSerializer(typeof(Character));

            foreach (string s in allCharFiles)
            {
                chars.Add(serializer.DeserializeFromFile(s) as Character);
            }
            serializer = new YAXSerializer(typeof(Encounter));
            foreach (string s in allEncFiles)
            {
                encounters.Add(serializer.DeserializeFromFile(s) as Encounter);
            }
            updateTabs(0, 0, 0);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Loads the specified emm file. It can be in either binary or xml format.
 ///
 /// If a file can not be found at the specified location, then a empty one will be returned.
 /// </summary>
 public static EMM_File LoadEmm(string path, bool returnEmptyIfNotValid = true)
 {
     if (Path.GetExtension(path) == ".emm")
     {
         return(new Xv2CoreLib.EMM.Parser(path, false).GetEmmFile());
     }
     else if (Path.GetExtension(path) == ".xml" && Path.GetExtension(Path.GetFileNameWithoutExtension(path)) == ".emm")
     {
         YAXSerializer serializer = new YAXSerializer(typeof(Xv2CoreLib.EMM.EMM_File), YAXSerializationOptions.DontSerializeNullObjects);
         return((Xv2CoreLib.EMM.EMM_File)serializer.DeserializeFromFile(path));
     }
     else
     {
         if (returnEmptyIfNotValid)
         {
             return(new EMM_File()
             {
                 I_08 = 0,
                 Materials = AsyncObservableCollection <Material> .Create()
             });
         }
         else
         {
             throw new FileNotFoundException("An .emm could not be found at the specified location.");
         }
     }
 }
Ejemplo n.º 7
0
        public static ToolSettings Load()
        {
            XmlSerializer xml = new XmlSerializer(typeof(ToolSettings));

            if (File.Exists(SettingsPath))
            {
                YAXSerializer serializer = new YAXSerializer(typeof(ToolSettings), YAXSerializationOptions.DontSerializeNullObjects);
                ToolSettings  settings   = (ToolSettings)serializer.DeserializeFromFile(SettingsPath);

                if (settings == null)
                {
                    settings = new ToolSettings()
                    {
                        GameLanguage = Language.English
                    };
                    settings.Save();
                }

                return(settings);
            }
            else
            {
                var settings = new ToolSettings()
                {
                    GameLanguage = Language.English
                };
                settings.Save();
                return(settings);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Loads the specified emb file. It can be in either binary or xml format.
 ///
 /// If a file can not be found at the specified location, then a empty one will be returned.
 /// </summary>
 public static EMB_File LoadEmb(string path, bool returnEmptyIfNotValid = true)
 {
     if (Path.GetExtension(path) == ".emb")
     {
         return(new Xv2CoreLib.EMB_CLASS.Parser(path, false).GetEmbFile());
     }
     else if (Path.GetExtension(path) == ".xml" && Path.GetExtension(Path.GetFileNameWithoutExtension(path)) == ".emb")
     {
         YAXSerializer serializer = new YAXSerializer(typeof(Xv2CoreLib.EMB_CLASS.EMB_File), YAXSerializationOptions.DontSerializeNullObjects);
         return((Xv2CoreLib.EMB_CLASS.EMB_File)serializer.DeserializeFromFile(path));
     }
     else
     {
         if (returnEmptyIfNotValid)
         {
             return(new Xv2CoreLib.EMB_CLASS.EMB_File()
             {
                 I_08 = 37568,
                 I_10 = 0,
                 UseFileNames = true,
                 Entry = new ObservableCollection <EmbEntry>()
             });
         }
         else
         {
             throw new FileNotFoundException("An .emb could not be found at the specified location.");
         }
     }
 }
        public GroupElement LoadModel()
        {
            YAXSerializer yaxSerializer       = new YAXSerializer(typeof(Element));
            GroupElement  deserializeFromFile = yaxSerializer.DeserializeFromFile(_fileName) as GroupElement;

            return(deserializeFromFile);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Parse the xml at the specified path and convert it into a binary .hci file, and save it at the same path minus the .xml.
        /// </summary>
        public static void Write(string xmlPath)
        {
            string        saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer   = new YAXSerializer(typeof(HCI_File), YAXSerializationOptions.DontSerializeNullObjects);
            var           oblFile      = (HCI_File)serializer.DeserializeFromFile(xmlPath);

            File.WriteAllBytes(saveLocation, oblFile.Write());
        }
Ejemplo n.º 11
0
        public static void SaveXml(string xmlPath)
        {
            string        path       = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer = new YAXSerializer(typeof(AMK_File), YAXSerializationOptions.DontSerializeNullObjects);
            AMK_File      amkFile    = (AMK_File)serializer.DeserializeFromFile(xmlPath);

            amkFile.Save(path);
        }
Ejemplo n.º 12
0
        public Deserializer(string location)
        {
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location));
            YAXSerializer serializer = new YAXSerializer(typeof(QSF_File), YAXSerializationOptions.DontSerializeNullObjects);

            qsf_File = (QSF_File)serializer.DeserializeFromFile(location); WriteFile();
            SaveBinaryFile();
        }
Ejemplo n.º 13
0
 public void LoadSettings()
 {
     _mSerializer = new YAXSerializer(typeof(FrameSettings), 
                                     YAXExceptionHandlingPolicies.ThrowErrorsOnly, 
                                     YAXExceptionTypes.Warning);
     _mFrameSettings = (FrameSettings)_mSerializer.DeserializeFromFile("data\\settings.xml");
     FrameworkSettings.Load(_mFrameSettings);
 }
Ejemplo n.º 14
0
        public static void LoadXmlAndSave(string xmlPath)
        {
            string        saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));
            YAXSerializer serializer   = new YAXSerializer(typeof(DSE_File), YAXSerializationOptions.DontSerializeNullObjects);
            DSE_File      dseFile      = (DSE_File)serializer.DeserializeFromFile(xmlPath);

            byte[] bytes = dseFile.GetBytes();
            File.WriteAllBytes(saveLocation, bytes);
        }
Ejemplo n.º 15
0
        public static void ConvertFromXml(string xmlPath)
        {
            string saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath));

            YAXSerializer serializer = new YAXSerializer(typeof(CharaSlotsFile), YAXSerializationOptions.DontSerializeNullObjects);
            var           file       = (CharaSlotsFile)serializer.DeserializeFromFile(xmlPath);

            file.SaveFile(saveLocation);
        }
 public AutocompleteList LoadList()
 {
     if (File.Exists(_filePath))
     {
         var serializer       = new YAXSerializer(typeof(AutocompleteList));
         var autocompleteList = serializer.DeserializeFromFile(_filePath) as AutocompleteList;
     }
     return(null);
 }
Ejemplo n.º 17
0
        public Deserializer(string fileLocation)
        {
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(fileLocation), Path.GetFileNameWithoutExtension(fileLocation));
            YAXSerializer serializer = new YAXSerializer(typeof(EMB_File), YAXSerializationOptions.DontSerializeNullObjects);

            embFile = (EMB_File)serializer.DeserializeFromFile(fileLocation);
            WriteBinaryEmb();
            File.WriteAllBytes(saveLocation, bytes.ToArray());
        }
Ejemplo n.º 18
0
        public Deserializer(string location)
        {
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location));
            YAXSerializer serializer = new YAXSerializer(typeof(BSA_File), YAXSerializationOptions.DontSerializeNullObjects);

            bsaFile    = (BSA_File)serializer.DeserializeFromFile(location);
            EntryCount = (bsaFile.BSA_Entries != null) ? bsaFile.BSA_Entries[bsaFile.BSA_Entries.Count() - 1].Index + 1 : 0;
            Write();
            File.WriteAllBytes(saveLocation, bytes.ToArray());
        }
Ejemplo n.º 19
0
        public Deserializer(string location)
        {
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location));
            YAXSerializer serializer = new YAXSerializer(typeof(CMS_File), YAXSerializationOptions.DontSerializeNullObjects);

            cmsFile = (CMS_File)serializer.DeserializeFromFile(location);
            Validation();
            Write();
            File.WriteAllBytes(saveLocation, bytes.ToArray());
        }
Ejemplo n.º 20
0
        private UpdateInfo DownloadFile()
        {
            //Get the temp file path and ensure the directory exists
            string localPath = Path.GetFullPath(String.Format("{0}/{1}/updateinfo.xml", Path.GetTempPath(), GeneralInfo.AppName));

            if (!Directory.Exists(Path.GetDirectoryName(localPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(localPath));
            }

            //Download file
            try
            {
                using (var client = new WebClient())
                {
                    client.DownloadFile(updateServer, localPath);
                }
            }
            catch
            {
                GotResponseFromServer = false;
                return(new UpdateInfo());
            }


            //Load the xml
            try
            {
                YAXSerializer serializer = new YAXSerializer(typeof(UpdateInfo), YAXSerializationOptions.DontSerializeNullObjects);
                var           xml        = (UpdateInfo)serializer.DeserializeFromFile(localPath);
                GotResponseFromServer = true;

                //Delete the xml
                if (File.Exists(localPath))
                {
                    File.Delete(localPath);
                }

                //Return the file
                return(xml);
            }
            catch
            {
                GotResponseFromServer = false;
                if (File.Exists(localPath))
                {
                    File.Delete(localPath);
                }
                return(new UpdateInfo());
            }
        }
Ejemplo n.º 21
0
        public static void SaveAfs2File(string filePath)
        {
            if (!Directory.Exists(Path.GetDirectoryName(filePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            }
            string        saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
            YAXSerializer serializer   = new YAXSerializer(typeof(AFS2_File), YAXSerializationOptions.DontSerializeNullObjects);
            AFS2_File     utfFile      = (AFS2_File)serializer.DeserializeFromFile(filePath);

            byte[] header;
            byte[] bytes = WriteAfs2File(utfFile, out header);
            File.WriteAllBytes(saveLocation, bytes);
        }
Ejemplo n.º 22
0
        public Deserializer(string location)
        {
            writeXmlMode = true;
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location));
            YAXSerializer serializer = new YAXSerializer(typeof(EAN_File), YAXSerializationOptions.DontSerializeNullObjects);

            eanFile = (EAN_File)serializer.DeserializeFromFile(location);
            eanFile.ValidateAnimationIndexes();
            eanFile.SortEntries();
            nonHierarchalBones = eanFile.Skeleton.GetNonHierarchalBoneList();
            ValidateAnimationBones();
            Write();
            File.WriteAllBytes(saveLocation, bytes.ToArray());
        }
Ejemplo n.º 23
0
        public Deserializer(string location)
        {
            saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location));
            YAXSerializer serializer = new YAXSerializer(typeof(BCS_File), YAXSerializationOptions.DontSerializeNullObjects);

            bcsFile = (BCS_File)serializer.DeserializeFromFile(location);
            bcsFile.SortEntries();

            PartSetCount   = (bcsFile.PartSets != null) ? int.Parse(bcsFile.PartSets[bcsFile.PartSets.Count() - 1].Index) + 1 : 0;
            PartColorCount = (bcsFile.Part_Colors != null) ? int.Parse(bcsFile.Part_Colors[bcsFile.Part_Colors.Count() - 1].Index) + 1 : 0;
            BodyCount      = (bcsFile.Bodies != null) ? int.Parse(bcsFile.Bodies[bcsFile.Bodies.Count() - 1].Index) + 1 : 0;

            Write();
            File.WriteAllBytes(saveLocation, bytes.ToArray());
        }
Ejemplo n.º 24
0
        private static void TryYax()
        {
            var obj = CreateFakeObject();

            obj.SetValues();

            var serializer = new YAXSerializer(typeof(Parameters),
                                               YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Error,
                                               YAXSerializationOptions.DontSerializeCyclingReferences | YAXSerializationOptions.DontSerializeNullObjects | YAXSerializationOptions.DontSerializePropertiesWithNoSetter);
            var someString = serializer.Serialize(obj);

            File.WriteAllText("yax.xml", someString);

            var back = serializer.DeserializeFromFile("yax.xml");
        }
Ejemplo n.º 25
0
        public bool DebugLoadXml()
        {
            string path = $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}/AcbFormatHelper.xml";

            if (File.Exists(path))
            {
                YAXSerializer serializer = new YAXSerializer(typeof(AcbFormatHelperMain), YAXSerializationOptions.DontSerializeNullObjects);
                AcbFormatHelperMain = (AcbFormatHelperMain)serializer.DeserializeFromFile(path);
                return(true);
            }
            else
            {
                AcbFormatHelperMain = new AcbFormatHelperMain();
                return(false);
            }
        }
Ejemplo n.º 26
0
 public static BCM_File Load(string path)
 {
     if (Path.GetExtension(path) == ".bcm")
     {
         return(new Parser(path, false).GetBcmFile());
     }
     else if (Path.GetExtension(path) == ".xml" && Path.GetExtension(Path.GetFileNameWithoutExtension(path)) == ".bcm")
     {
         YAXSerializer serializer = new YAXSerializer(typeof(BCM_File), YAXSerializationOptions.DontSerializeNullObjects);
         return((BCM_File)serializer.DeserializeFromFile(path));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 27
0
        public static DeserializedProgram Deserialize(string filename)
        {
            YAXSerializer serializer = new YAXSerializer(typeof(SourceFile));

            try
            {
                object deserializedObject = serializer.DeserializeFromFile(filename);
                if (deserializedObject != null)
                {
                    SourceFile sourceFile = (SourceFile)deserializedObject;
                    sourceFile.Namespace.VirtualInstrument.BlockDiagram.DeserializedProgram = Wrap.WrapIntoStruct(sourceFile.Namespace.VirtualInstrument.BlockDiagram);
                    return(sourceFile.Namespace.VirtualInstrument.BlockDiagram.DeserializedProgram);
                }
                throw new IOException("Deserializing XML is failed");
            }
            catch
            {
                throw new IOException("Deserializing XML is failed");
            }
        }
Ejemplo n.º 28
0
        public static GameDirXml LoadSettings()
        {
            try
            {
                //Try to load the settings
                YAXSerializer serializer = new YAXSerializer(typeof(GameDirXml), YAXSerializationOptions.DontSerializeNullObjects);
                return((GameDirXml)serializer.DeserializeFromFile(GeneralInfo.SettingsPath));
            }
            catch
            {
                //If it fails, create a new instance and save it to disk.
                var newSettings = new GameDirXml()
                {
                    GameDirectory = null
                };

                newSettings.SaveSettings();

                return(newSettings);
            }
        }
Ejemplo n.º 29
0
 bool ReadXmlFile()
 {
     if (!File.Exists(directoryLocation + "/EmbIndex.xml"))
     {
         Console.WriteLine("Could not find \"EmbIndex.xml\"\n" +
                           "Extraction failed.");
         Console.ReadLine();
         return(false);
     }
     try
     {
         YAXSerializer serializer = new YAXSerializer(typeof(EmbIndex));
         EmbIndexXml = (EmbIndex)serializer.DeserializeFromFile(directoryLocation + "/EmbIndex.xml");
         return(true);
     }
     catch
     {
         Console.WriteLine("Could not read \"EmbIndex.xml\". It is corrupted!\n" +
                           "Extraction failed.");
         Console.ReadLine();
         return(false);
     }
 }
Ejemplo n.º 30
0
        public MyNetworkState LoadState(string fileName)
        {
            try
            {
                YAXSerializer serializer = new YAXSerializer(typeof(MyNetworkState),
                                                             YAXExceptionHandlingPolicies.ThrowErrorsOnly,
                                                             YAXExceptionTypes.Warning);

                MyNetworkState networkState = (MyNetworkState)serializer.DeserializeFromFile(fileName);

                if (Owner.Name != networkState.ProjectName)
                {
                    throw new InvalidDataException("Different network state file: " + networkState.ProjectName);
                }
                MyMemoryManager.Instance.LoadBlocks(this, true, networkState.MemoryBlocksLocation);

                return(networkState);
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Restoring state failed: " + e.Message);
                return(new MyNetworkState());
            }
        }